LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 04-27-2004, 04:16 AM   #1
vtluu
LQ Newbie
 
Registered: Mar 2004
Location: Vietnam
Posts: 9

Rep: Reputation: 0
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 S {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 at the same time. Are the both libraries implemented in glibstdc++?

Any help will be appreciated.

Luu Vo.

Last edited by vtluu; 04-27-2004 at 04:21 AM.
 
Old 05-21-2004, 10:45 AM   #2
John Boncek
LQ Newbie
 
Registered: May 2004
Posts: 3

Rep: Reputation: 0
The line:

static enum E {A=0, B, C};

creates an enum type called E, not an object. Only objects can be static. If what you wanted here was the definition of a static enum object called E, use something like:

static enum EType {A=0, B, C} E;

which creates an enum type called EType and a static object of that type called E.

I am unsure if a similar problem affects your struct line, but try removing the extern "C". In most C/C++ systems I am familiar with, extern "C" applies only to functions. I haven't used it in this one.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple Ooo BASIC Macro problem: "connot coerce argument type..." tredegar Linux - Software 0 08-14-2005 10:00 AM
web surfing problem... i have to type in "http://" fatrandy13 Linux - Software 8 05-23-2005 02:48 AM
Hi dakensta- one more problem- "Not an aggregate type" ashwinipahuja Programming 3 04-30-2004 06:42 AM
extern "C" and static data type problem with g++ vtluu Programming 2 04-28-2004 05:10 AM
<input type="button" disabled="true" > does not work in ns4.7 or 4.9 cybercop12us Programming 2 11-29-2002 08:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration