Illegal Storage Class error with externs

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Illegal Storage Class error with externs

Jump to solution
2,904 Views
bhamilton
Contributor I

I'm working on an HCS08 project, using CW 6.2, in C with a few source files and 1 header file containing all the common information, including declarations of some global variables.  They're all defined in the header as extern, and declared in the various source files wherever it makes the most sense for them to live.

 

Whenever I go to compile any of the source files in the project, the compiler gets to the global declarations and spits out "Error: C1005: Illegal storage class".  CW help has a fairly useless description of what this means, but from the example and tip given I can guess that the compiler doesn't like my use of extern here, although I can't figure out why.

 

I've tried moving the globals around in the .h file and the problem follows them, so it's not an issue with a surrounding line of code.  I went through the preprocessed files looking for a duplicate name on the declared variables and found nothing.

 

Can anybody suggest other things I might look for, or clarify under what conditions an extern might result in a C1005 error?

Labels (1)
Tags (1)
0 Kudos
1 Solution
617 Views
stanish
NXP Employee
NXP Employee

This might be caused by the missing semicolon at the end of prototypes or data declarations in the header file.

 

Stanish

View solution in original post

0 Kudos
5 Replies
618 Views
stanish
NXP Employee
NXP Employee

This might be caused by the missing semicolon at the end of prototypes or data declarations in the header file.

 

Stanish

0 Kudos
617 Views
bhamilton
Contributor I

Gads.  Stanish was right, it was a missing semicolon nowhere near the externs.

 

C compiler error messages confound me yet again.

 

Thanks for the help!

Message Edited by bhamilton on 2009-04-14 09:36 AM
0 Kudos
617 Views
irob
Contributor V

Wow, same here.  I wasted a good 1 hour on this before giving up and consulting the forums.  Should have started with the forums!  I would never have guessed a missing semicolon, based ont he error code.

 

Thanks!

0 Kudos
617 Views
pgo
Senior Contributor V

Dear bhamilton,

 

Can you provide an example of your definition from the header file and the corresponding declaration in the C file?

 

Bit hard to suggest reasons otherwise :smileyhappy:

 

You can get similar errors if the memory model changes betweem the declaration and definition (from memory).

 

Also - is the error occurcing when the header file or the C file is being compiled?

 

 

bye

Message Edited by pgo on 2009-04-14 08:12 PM
0 Kudos
617 Views
CrasyCat
Specialist III

Hello

 

You should be able to declare external storage for variables in a .h file.

 

You may have an issue some other place.

 

Did you try to generate the pre-processor output for one of your source file?

Looking at listing file after pre-processing might explain what is going on here.

 

Do you have a #define extern somewhere in the application?

 

If this does not help, I need to get a look at the preprocessor listing file.

 

 

CrasyCat

0 Kudos