[tbm at cyrius.com: Bug#441533: GCC 4.3 related: missing #includes]

Marc Glisse marc.glisse at normalesup.org
Wed Dec 12 12:47:34 CET 2007

[no need to cc: me, I read the list]

On Tue, 11 Dec 2007, Steve M. Robbins wrote:

>> Besides, I don't think there is a missing #include in gmp.h, the error lies
>> elsewhere. The code with FILE in gmp.h is protected by a check that the
>> stdio header was included. Now I believe the issue is that the glibc/gcc
>> standard headers are c++-buggy in the sense that including stdio.h puts
>> FILE only in the global namespace and not also in the std:: namespace as it
>> should.

Note that this may change in the next standard, to make things simpler...

> I'm never sure what header should declare what.
> Where did you find such a list?

C++ standard, paragraph D.5 (about what C headers should do)
               paragraph 27.8.2 about cstdio

>> Note that it is a documented feature of gmp that you need to include
>> stdio.h/cstdio before gmp.h if you want the FILE related functions.
> Well, the docs do mention stdio.h, but not cstdio.

Ok, but the C++ standard mentions using cstdio instead of stdio.h (though 
gmp doc could mention cstdio).

>> Now the reason for not including stdio by default for gmp is I think less
>> relevant for C++ than for C, and it could make sense to always include it
>> for C++ the way S. Robbins suggests.
> That strikes me as a good change.
> It would be less surprising to the programmer, as not everyone reads
> the docs from cover to cover.  If you look only at, say, the docs for
> gmp_fprintf(), you won't see anything about #including stdio.h.

But if you are using gmp_fprintf, you have a FILE* in your code, so you 
are already including stdio.h/cstdio (though not necessarily before gmp.h, 
I admit).

> Incidentally: why not include stdio.h by default?

I think the reasons are to support platforms that do not have stdio, and 
to make it possible to have lighter binaries on platforms that do have 
stdio when we don't need it. These reasons are less relevant for C++. But 
I don't remember for sure (note that I am only trying to tell what I know, 
I tend to agree that including stdio.h by default would be easier).

Marc Glisse

PS: thanks for the new debian ipe.

More information about the gmp-bugs mailing list