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?
已解决! 转到解答。
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!
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!
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
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
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