PDA

View Full Version : C warning: useless storage class specifier in empty declaration


bobleny
02-26-2010, 04:57 AM
This is basically the same thing as the last warning I asked about. This time it is about a structure.

The structure:

typedef struct node
{
// Next available memory location
pNode next;
// The memory location of the content struct
pContent data;
}; // The error is actually reported right here


I thought it had something to do with this line here, which is above the structure,:

typedef struct node *pNode;

but when you remove that line, the warning doesn't change. Of course I get a billion other warnings as expected...

Does this have something to do with the way the structure is declared?
I see structures declared like that all the time, but I also see them declared like this:

typedef struct
{
// Stuff
}node;


I pretty sure I've seen them declared in other ways too. The second structure doesn't seem to work in this case though. What is the difference?

oracleguy
02-26-2010, 06:11 AM
Declare it the second way you show and you won't get that warning.

bobleny
02-26-2010, 06:58 PM
Is it better to do it the second way? The error does go away, but I get a bunch of new errors.

oracleguy
02-26-2010, 07:40 PM
It gets rid of the warning, so yes.