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

12,332

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.

Share:
12,332

Related videos on Youtube

Angelo
Author by

Angelo

I enjoy working with mobile and embedded technologies and researching latest tech.

Updated on May 06, 2022

Comments

  • Angelo
    Angelo about 2 years

    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?

  • Jonathan Leffler
    Jonathan Leffler over 13 years
    No; the compiler inserted the semi-colon as an attempt at error recovery.
  • Angelo
    Angelo over 13 years
    Thanks a lot for the answers. The problem seemed to be with the declaration of u8. So I included the file that has a definition for u8, and its working correctly now.
  • Angelo
    Angelo about 12 years
    Thanks a million, Jon.. Earlier I placed this comment in the wrong place :)