* extern C and static data type problem with g++
@ 2004-04-27 9:16 Luu Vo
2004-04-27 14:33 ` llewelly
0 siblings, 1 reply; 3+ messages in thread
From: Luu Vo @ 2004-04-27 9:16 UTC (permalink / raw)
To: gcc-help
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};
g++ said:
storage class specified for field `x'
`static' can only be specified for objects and functions
Is this just the implementation of g++? 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. Are the both libraries
implemented in glibstdc++?
Any help will be appreciated.
Luu Vo.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: extern C and static data type problem with g++
2004-04-27 9:16 extern C and static data type problem with g++ Luu Vo
@ 2004-04-27 14:33 ` llewelly
0 siblings, 0 replies; 3+ messages in thread
From: llewelly @ 2004-04-27 14:33 UTC (permalink / raw)
To: Luu Vo; +Cc: gcc-help
"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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: extern C and static data type problem with g++
@ 2004-04-27 9:30 Lev Assinovsky
0 siblings, 0 replies; 3+ messages in thread
From: Lev Assinovsky @ 2004-04-27 9:30 UTC (permalink / raw)
To: Luu Vo, gcc-help
Hi Luu!
enum in C&C++ is something like #define in the sence
of memory allocating. Nothing is allocated for #define and for enum as well.
The difference is #define is resolved in preprocessor time, when
enum tokens follow the scope rules (class, namespace) and do exist
at compile time.
Sorry for my English :(
----
Lev Assinovsky
Aelita Software Corporation
(now is a part of Quest Software)
O&S InTrust Framework Division, Team Leader
ICQ# 165072909
> -----Original Message-----
> From: Luu Vo [mailto:vtluu@tma.com.vn]
> Sent: Tuesday, April 27, 2004 1:14 PM
> To: gcc-help@gcc.gnu.org
> Subject: extern C and static data type problem with g++
>
>
> 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};
>
> g++ said:
>
> storage class specified for field `x'
> `static' can only be specified for objects and functions
>
> Is this just the implementation of g++? 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. Are the both libraries
> implemented in glibstdc++?
>
> Any help will be appreciated.
>
> Luu Vo.
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-04-27 14:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-27 9:16 extern C and static data type problem with g++ Luu Vo
2004-04-27 14:33 ` llewelly
2004-04-27 9:30 Lev Assinovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).