bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug in bits/stdio.h when used with GCC-3


From: Andreas Jaeger
Subject: Re: Bug in bits/stdio.h when used with GCC-3
Date: Sat, 25 Aug 2001 21:16:59 +0200
User-agent: Gnus/5.090004 (Oort Gnus v0.04) XEmacs/21.4 (Academic Rigor)

James Youngman <address@hidden> writes:

> Andreas Jaeger <address@hidden> writes:
>
>> James Youngman <address@hidden> writes:
>> 
>> > Description of problem:
>> >
>> > When compiling programs with optimisation, GCC defines the
>> > __USE_EXTERN_INLINES macro.  The /usr/include/bits/stdio.h header
>> > #defines a macro for printf in this case.  However, while this is
>> > probably fine for C, it breaks C++ programs where objects can have
>> > member functions called printf.  This macro is also not defined if the
>> > GCC version is earlier than 2.97.   Here is the offending code :-
>> 
>> The printf macro has been removed in glibc 2.2.4.
>
> OK; thanks. 
>
>> Nevertheless the C library is allowed to define printf as a macro in C
>> - and also all other functions.
>
> Yes, I agree that that is the case for the C language.  I am talking
> about the C++ language.  In C++, more than one function with the same
> name can exist. 

I said on purpose C library because I didn't check the C++ standard at
that time (but did in the meaintime).

> My understanding is that the following is a conforming C++ program,
> which should work :-
>
>   #include <stdio.h>

>   class foo { public: int printf(const char *fmt, ...); };
>   int main (int argc, char *argv[]) { return 0; }
>
> Do you disagree?   

Use:
#include <cstdio>

And report the bug to the GCC maintainers since they implement
<cstdio> ;-)

If you include <cstdio>, the implementation is not allowed to have
printf as macro.

This discussion touches the interface between C++ and C and it's
rather fragile and AFAIK needs reworking.  If you notice other
functions (besides those that are mandated as macros, like assert and
errno), please tell us and we'll fix it in glibc until a better
solution is found.

Andreas
-- 
 Andreas Jaeger
  SuSE Labs address@hidden
   private address@hidden
    http://www.suse.de/~aj



reply via email to

[Prev in Thread] Current Thread [Next in Thread]