Search code examples
cheaderextern

syntax error - token ";" inserted before "variable name"


I'm programming in C. I'm getting the following error:

ctc E208: ["..\..\ECB\Include\ecb.h" 4/11] syntax error - token ";"
inserted before "u8_vTeethBeforeMissingTeeth1"

Here is what I have in the .h file:

#ifndef __ECB_H__
#define __ECB_H__

extern u8 u8_vTeethBeforeMissingTeeth1;
extern u8 u8_vTeethBeforeMissingTeeth2;

#endif /* __ECB_H__ */

Can anyone please tell me what am I missing in this section of code?


Solution

  • The trouble is that your header is not self-contained. It relies on a type 'u8' which is not defined here (and not defined in any of the other headers you've included before this). You should include the header that defines 'u8' in your 'ecb.h' header before declaring your 'missing teeth' variables.

    Headers should be self-contained; if you need the services of the header, you should be able to include it without worrying about what else needs to be included. The standard C headers do that for you - you should do it for yourself with your own headers.