Compiling a C program with g++ 4.3.1 yields an error about std::FILE

Marc Glisse marc.glisse at
Tue Jun 10 14:05:20 CEST 2008

On Tue, 10 Jun 2008, Vincent Lefevre wrote:

>> When I want to compile a C program that includes both <stdio.h>
>> and <gmp.h> from GMP 4.2.2 (nothing else) with g++ 4.3.1 (no
>> problem with g++ < 4.2.x and earlier), I get the error:
>> /home/vlefevre/x86_64/gmp-debug/include/gmp.h:520: error: 'std::FILE' has not been declared

The documentation should probably say to include cstdio instead of (or in 
addition to) stdio.h for c++ (this is actually a bug in g++/glibc, but it 
won't be a bug anymore in the next c++ standard), for gmp-4.2.2.

An alternative would be to not use std::FILE but FILE and require users to 
include stdio.h even for c++ programs (although this header is deprecated 
for c++, but should be undeprecated in the next standard).

> BTW, this bug has been fixed in Debian:

Do they really include iostream (instead of cstdio) to get std::FILE? 
Their fix would be fine with cstdio, but iostream seems wrong.

Marc Glisse

More information about the gmp-bugs mailing list