This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: extern C and static data type problem with g++
- From: llewelly at xmission dot com
- To: "Luu Vo" <vtluu at tma dot com dot vn>
- Cc: <gcc-help at gcc dot gnu dot org>
- Date: 27 Apr 2004 08:33:44 -0600
- Subject: Re: extern C and static data type problem with g++
- References: <001d01c42c38$0582b7a0$cc62a8c0@LuuVo>
"Luu Vo" <vtluu@tma.com.vn> writes:
> In RH Linux 9, when compiling my C++ program with lines as below:
>
> extern "C" struct {int x};
> static enum E{A=0, B, C};
extern "C"
{
struct x {int x;};
enum e{a= 0, b, c};
}
>
> g++ said:
>
> storage class specified for field `x'
Maybe the gcc 3.4 diagnostic is better:
extrn.cc:3: error: ISO C++ prohibits anonymous structs
> `static' can only be specified for objects and functions
>
> Is this just the implementation of g++?
It is required by the ISO C++ standard.
> That means I can't use static and
> extern "C" for those lines of code?
>
> Another question: with GNU g++/gcc compiler and its C++ library, can I use
> both traditional C++ lib (e.g., classic iostream) and standard C++ lib
> (e.g., standard iostream) in my C++ program.
Any code which uses classic iostreams should be updated to use standard
iostreams.
GCC >= 3.0 does not support classic iostreams. "iostream.h" is just:
#include "backward_warning.h"
#include <iostream>
and some appropriate using declarations. For simple cases this is
backward-compatible with classic iostreams, but in some cases it
is not.
So if you tried to use 'both' you would really be using the same
iostreams in both places.
> Are the both libraries
> implemented in glibstdc++?
No.