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

Torbjorn Granlund tg at
Mon Jul 21 23:55:10 CEST 2008

Torbjorn Granlund <tg at> writes:

  Marc Glisse <marc.glisse at> writes:
    I know debian did it this way, but could you please put the #include line 
    one line higher? These standard files are not meant to be included in 
    weird situations like a namespace or a non-default linkage.
    Besides, the "using std::FILE" should now be unconditional. cstdio is 
    included in the line above so std::FILE must exist, but cstdio is included 
    after the long macro check that defines _GMP_H_HAVE_FILE so it is not 
    Maybe the include line would actually be best next to the iosfwd one at 
    the beginning of the header?
    Note: I am not discussing the ugliness of the solution, just trying to 
    make the result correct.
  So, this is what you're suggesting:
  At the beginning of the file:
  #if defined (__cplusplus)
  #include <iosfwd>   /* for std::istream, std::ostream, std::string */
  #include <cstdio>
  And around line 520:
  #if defined (__cplusplus)
  extern "C" {
  using std::FILE;
In C, we require users to include stdio.h for getting GMP I/O function
prototypes.  These changes include stdio for C++.  Shouldn't we
require the user to include it, like in C?


More information about the gmp-bugs mailing list