Compiler Error " Illegal storage class" in Header file

cancel
Showing results for 
Search instead for 
Did you mean: 

Compiler Error " Illegal storage class" in Header file

Jump to solution
9,075 Views
Hombre
Contributor I

CodeWarrior IDE Version 4.2.6.895

HCS12A256

 

Hi all,

 

i have a little problem with the Compiler. I am on a project to create a Bootloader running in RAM for reprogramming flash memory. The -Pic –PicRTS options are activated for position independent code.

The Problem is that I receive the Compiler Error “Illegal storage class” for this definition in a Header File:

 

typedef struct

{

 unsigned char data[0x800];

 …..

 …..     

} STR_FPGA_MEM;

 

 

I can’t see the problem. Could somebody help me?

 


Thanks

Daniel

 

Labels (1)
Tags (1)
0 Kudos
1 Solution
492 Views
CompilerGuru
NXP Employee
NXP Employee
Hi Daniel,

the code snippet you copied looks OK, so I could imagine two causes
- either it is in the parts you did cut away. For example a not correctly terminated declaration before the copied snippet
- or, and I guess that's the most likely explanation, you have some sort of name collision with a macro.
  could be data or STR_FPGA_MEM.
  Such problems are best seen with the preprocessor output, use the context menu in the project view.
  I could bet it a macro :smileyhappy:

Daniel

View solution in original post

0 Kudos
8 Replies
492 Views
bob_walker
Contributor III

I, too, have gotten bitten by this one. One would think that if the parsed line is unterminated by a semicolon, and the end of file is reached, an error for the offending line should be generated.

 

Who in their right mind would continue a C statement ACROSS files?!

0 Kudos
492 Views
CompilerGuru
NXP Employee
NXP Employee

Well, it's legal in ANSI C.

And there may be some uses for it when including the same file multiple times with different defines.

I agree that normally you would not do this for a statement, but for example it could make sense to do it for initialization data.

 

You can propose this as feature request using the support system to at least issue a warning when a statement crosses multiple files.

 

Daniel

0 Kudos
493 Views
CompilerGuru
NXP Employee
NXP Employee
Hi Daniel,

the code snippet you copied looks OK, so I could imagine two causes
- either it is in the parts you did cut away. For example a not correctly terminated declaration before the copied snippet
- or, and I guess that's the most likely explanation, you have some sort of name collision with a macro.
  could be data or STR_FPGA_MEM.
  Such problems are best seen with the preprocessor output, use the context menu in the project view.
  I could bet it a macro :smileyhappy:

Daniel

View solution in original post

0 Kudos
492 Views
PaoloSubiaco
Contributor I
Hi add this post just for reference for those who see the same compile error:
in my case, I forgot the semicolon after a declaration in one include file:

// File rtc.h
// ........
// Function prototypes
void oneFunction(void);
unsigned char secondFunction(void);
void thirdFunction(void)

//End of rtc.h : Look at the last function, not terminated by semicolon!!!


I spent about two hours to discover this error.... Codewarrior compiler should be improved, though.
Best regards. Paolo
0 Kudos
492 Views
Lundin
Senior Contributor IV

Didn't you rather get two errors? First "illegal storage class" and then "missing semicolon".

 

Also, if you haven't gotten burned by strange missing semicolon errors over and over yet, don't worry. This is an initation rite all C programmers have to go through during their first 5 years or so, until they eventually learn to type out semicolons in their sleep. :smileyhappy:

 

0 Kudos
492 Views
irob
Contributor V

Truer words, never spoken, Lundin.

0 Kudos
492 Views
irob
Contributor V

Wow, this got me too!  Even with the hint of it being a prototype declaration, it still took me a while to find.

0 Kudos
492 Views
Hombre
Contributor I
Hi,
 
thanks for help Daniel. Finally i found the macro :smileyhappy:
 
Best regards
Daniel
0 Kudos