This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: 3.3 problem: <ctype.h> and <iostream>
- From: Matt Austern <austern at apple dot com>
- To: Craig Rodrigues <rodrigc at attbi dot com>
- Cc: gcc at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Wed, 22 Jan 2003 16:47:43 -0800
- Subject: Re: 3.3 problem: <ctype.h> and <iostream>
On Wednesday, January 22, 2003, at 04:34 PM, Craig Rodrigues wrote:
Hi,
I just did a contrib/gcc_update in my CVS tree on the 3.3 branch
and am now encountering a new problem.
If I have the following file:
#include <ctype.h>
#include <iostream>
#include <ios>
int main(int argc, char *argv[])
{
}
Compiling it yields the following error on RedHat Linux 7.2 system:
=======================================================================
============
In file included from /u0/test/gcc-3.3-cvs/test/include/c++/3.3/ios:48,
from
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/ostream:45,
from
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/iostream:45,
from a.cc:2:
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:58:34:
macro "isspace" pas
sed 2 arguments, but takes just 1
In file included from /u0/test/gcc-3.3-cvs/test/include/c++/3.3/ios:48,
from
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/ostream:45,
from
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/iostream:45,
from a.cc:2:
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:58: error: `
std::isspace' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:58: error:
template
declaration of `bool std::isspace'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:62:34:
macro "isprint" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:62: error: `
std::isprint' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:62: error:
template
declaration of `bool std::isprint'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:66:34:
macro "iscntrl" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:66: error: `
std::iscntrl' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:66: error:
template
declaration of `bool std::iscntrl'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:70:34:
macro "isupper" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:70: error: `
std::isupper' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:70: error:
template
declaration of `bool std::isupper'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:74:34:
macro "islower" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:74: error: `
std::islower' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:74: error:
template
declaration of `bool std::islower'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:78:34:
macro "isalpha" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:78: error: `
std::isalpha' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:78: error:
template
declaration of `bool std::isalpha'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:82:34:
macro "isdigit" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:82: error: `
std::isdigit' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:82: error:
template
declaration of `bool std::isdigit'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:86:34:
macro "ispunct" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:86: error: `
std::ispunct' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:86: error:
template
declaration of `bool std::ispunct'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:90:35:
macro "isxdigit" pa
ssed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:90: error: `
std::isxdigit' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:90: error:
template
declaration of `bool std::isxdigit'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:94:34:
macro "isalnum" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:94: error: `
std::isalnum' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:94: error:
template
declaration of `bool std::isalnum'
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:98:34:
macro "isgraph" pas
sed 2 arguments, but takes just 1
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:98: error: `
std::isgraph' declared as an `inline' variable
/u0/test/gcc-3.3-cvs/test/include/c++/3.3/bits/localefwd.h:98: error:
template
declaration of `bool std::isgraph'
=======================================================================
============
If I change the order of the includes to:
#include <iostream>
#include <ios>
#include <ctype.h>
Then the error goes away.
What's going on here?
Looks pretty clear. You're picking up a version of <ctype.h> that's
appropriate for C, instead of one that's appropriate for C++. The C
version of <ctype.h> declares a whole bunch of macros, and the
C++ version shouldn't. In a C++ compilation you should either get
a completely different header, or else a header that's conditionalized
on #ifdef __cplusplus. Somehow the machinery to do that broke.
--Matt