Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > multiple storage classes: error

Reply
Thread Tools

multiple storage classes: error

 
 
Daniel Schüle
Guest
Posts: n/a
 
      11-28-2005
Hello all,

I get the error when I try to compile this code

// .h file

typedef static int (*get)(void); // (*)
typedef static void (*set)(int); //

// .c file

// forward methods
static int getAMethod(void);
static void setAMethod(int);

static struct foo {
get getA;
set setA;
// and so on
}bar = {
.getA = getAMethod,
.setA = setAMethod,
};

// implement methods
static int getAMethod(void) { // do something with bar }
static void setAMethod(int value) { // the same }

-----------------------------
when I remove "static" in (*) then compiler (gcc3.3.5) accepts it
Is "static" not allowed in typedef declarations like this or why is the code
rejected?

And one more question ... suppose I would have

struct foo {
static get getA;
static set setA;
} bar;

what would be the semantic of the "static" in this context?
I come from C++, I dont know is this construct is allowed.
I only know for sure "const" would be ok there.

Thx for your answers
Regards, Daniel


 
Reply With Quote
 
 
 
 
Ingo Menger
Guest
Posts: n/a
 
      11-28-2005

Daniel Schüle schrieb:

> Is "static" not allowed in typedef declarations like this or why is the code
> rejected?


Exactly.

> And one more question ... suppose I would have
>
> struct foo {
> static get getA;
> static set setA;
> } bar;
>
> what would be the semantic of the "static" in this context?


None, since only well formed programs may have semantics.

> I come from C++,


I see. In C, write the static members outside the struct to get nearly
the same effect. All code referencing the static members must be in the
same source file.

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why is enterprise storage so much more expensive than personal storage? John Computer Support 4 03-17-2008 09:50 PM
How to access the external storage unit of storage router =?Utf-8?B?SWduYXRpdXM=?= Wireless Networking 4 11-06-2006 06:40 AM
Difference b/w storage class and storage class specifier sarathy C Programming 2 07-17-2006 05:06 PM
Storage device for digital pictures rather than buying multiple cards? MayorMac@sisna.com Digital Photography 11 05-04-2005 07:32 PM
SQLServer Session storage and multiple sites Dave Wright ASP .Net 3 02-09-2004 08:20 AM



Advertisments