POSIX features disappear with g++

tim@timsplace.dk tim@timsplace.dk
Mon Oct 15 02:02:00 GMT 2001


Hi there. I'm writing a C++ application which needs to acces some shared
memory and I'm using the Posix functions for this. The code compiles fine
with gcc but when I'm using g++ it complaints that the function ftruncate
is not defined.

OS: Linux 2.4.2
g++ version: 2.95.3

The code (partly):
        shm_descr = shm_open(SHM_AREA_NAME, O_CREAT|O_RDWR, S_IRUSR);
        if (ftruncate(shm_descr, 42)<0)
                perror("ftruncate");

Running gcc (gcc -lrt test.c)
	Works like a charm.

Running g++ (g++ -lrt test.c)
	test.c: In function `int main(int, char **)':
	test.c:23: implicit declaration of function `int ftruncate(...)'

Does anyone have an idea what's going on?

/Tim



More information about the Gcc-help mailing list