This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: G++ 2.9.5 undefined reference to stdlibfunction problem.
- To: Ross Nicoll <rnicoll at lostics dot demon dot co dot uk>
- Subject: Re: G++ 2.9.5 undefined reference to stdlibfunction problem.
- From: Mumit Khan <khan at xraylith dot wisc dot EDU>
- Date: Tue, 03 Aug 1999 21:18:44 -0500
- cc: gcc-bugs at gcc dot gnu dot org
Ross Nicoll <rnicoll@lostics.demon.co.uk> writes:
> This is probably just me being stupid, but I'm all out of ideas to fix
> this.
>
> I have some C++ code that uses the function fdopen(). Although I have
> verified that the correct include is included, and even read the include
> by hand, g++ still claims:
>
> log.cpp: In method `void Log::Write(char *, ...)':
> log.cpp:96: implicit declaration of function `int fdopen(...)'
> log.cpp:96: assignment to `FILE *' from `int' lacks a cast
You really need to provide some system/OS info. What system are you
running on?
Note that fdopen is NOT ANSI, but rather specified by POSIX, and some
system may require defining a preprocessor macro to access the POSIX
interfaces (eg., -D_POSIX_SOURCE).
See http://gcc.gnu.org/faq.html#bugreport for what you need to send.
>
>
> If I kludge this by putting the declaration into the file by hand, it
> accepts it, until compile time, when it complains (log.cpp is part of
> libe++commerce.a BTW):
>
> g++ -L../lib -le++commerce test.o -o test.cgi
> ../lib/libe++commerce.a: In function `Log::Write(char *,...)':
> /home/rnicoll/development/e++commerce/lib/log.cpp:96: undefined reference
> to `fdopen(int, char const *)'
> collect2: ld returned 1 exit status
You forgot to specify "C" linkpage for fdopen.
extern "C" int fdopen (int, const char*);
Perhaps you ought to look at the docs for your C runtime library.
Regards,
Mumit