This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: system calls in gcc-2.96 under RedHat Linux 7.0
- To: Dirk Petry <petry at iastate dot edu>
- Subject: Re: system calls in gcc-2.96 under RedHat Linux 7.0
- From: Alexandre Oliva <aoliva at redhat dot com>
- Date: 19 Jan 2001 17:12:40 -0200
- Cc: gcc-bugs at gcc dot gnu dot org, bug-gcc at gnu dot org
- Organization: GCC Team, Red Hat
- References: <3A688AC1.7AFD900F@iastate.edu>
On Jan 19, 2001, Dirk Petry <petry@iastate.edu> wrote:
> I have an awkward problem with gcc-2.96 under RedHat 7.0
> when trying to compile C code containing the system calls
> "read", "write" and "close" to be linked to a C++ main
> programm:
These are not system calls, in a strict sense. They're functions
defined in the C library, and C++ requires any functions to be
declared before they're used. Recent releases of GCC have been
stricter about requiring the declaration. Just #include the
appropriate header files and all will be fine.
> serial.c:62: warning: implicit declaration of function `int close(...)'
> serial.c:86: warning: implicit declaration of function `int write(...)'
> serial.c:101: warning: implicit declaration of function `int read(...)'
This was a hint that you should have fixed your program before the
construct started to be deemed as invalid :-)
> And even more interesting: If I compile under RedHat 7.0 using "gcc"
> instead of "g++", the program compiles, but it doesn't link
> with the rest of the program:
> vdcmon.o: In function `sercom::~sercom(void)':
> vdcmon.o(.text+0x3995): undefined reference to `terminate_serial(int *)'
> ...
> and similar error messages from ld.
It's likely that terminate_serial was compiled as C, and the call was
compiled as C++, but the function was not declared as extern "C", so
the call ended up using a mangled name.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist *Please* write to mailing lists, not to me