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

Vincent Lefevre vincent at
Tue Jun 10 09:27:50 CEST 2008

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

This corresponds to:

#if defined (__cplusplus)
extern "C" {
using std::FILE;

I don't know whether this is a bug in GMP or in g++, or a bug in the
GMP documentation, which states:

3.1 Headers and Libraries

All declarations needed to use GMP are collected in the include file
`gmp.h'.  It is designed to work with both C and C++ compilers.

     #include <gmp.h>

   Note however that prototypes for GMP functions with `FILE *'
parameters are only provided if `<stdio.h>' is included too.

     #include <stdio.h>
     #include <gmp.h>

Vincent Lefèvre <vincent at> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

More information about the gmp-bugs mailing list