#305 Forgetting ';' at the end in .h file produce strange errors


Dear Sir or Madame

If there is a program consisting of both a .h and .c

and the xxx.h file looks like this


extern unsigned char I2CSWDriver_Read(I2CSWDriverResult_t result, I2CSWDriverFlag_t flag)


and .c file do
#include "xxx.h"

The compiler will produce strange error message, like "old C style declaration" and sometimes no error messages at all,

The error lies in that there is a missing ';' at the end of the extern declaration of the function, this "falls over" to the .c file

I must suggest that the compiler warn for this, that is, if a unfinished declaration exist in the .h file when the .h file ends.



  • Stefan Olsson

    Stefan Olsson - 2010-11-16

    Dear Sir or Madame

    I forgot to include the compiler version

    SDCC : mcs51/gbz80/z80/avr/ds390/pic16/pic14/TININative/xa51/ds400/hc08 2.9.0 #5416 (Feb 3 2010) (UNIX)

  • Raphael Neider

    Raphael Neider - 2010-11-16

    This behaviour is the same with GCC (and every other C preprocessor for that matter), and since SDCC uses the GNU C preprocessor I suggest you file your complaint with the GNU project. We just use a (nearly) unmodified version of that software.

    However, the preprocessor cannot well warn on such things as it is not (well, only to a veeeery small extent such as the lexical structure of numbers and identifiers) aware of the language it is preprocessing. The compiler could interpret the #line directives that might be emitted by the preprocessor on file changes and try to warn on such unfinisched declarations, but I doubt that such an approach is feasible: I have more than once used the #include directive to do Ugly Things (TM) that might rely on the preprocessor inserting seemingly random stuff into a compilable program (definitions of enum values and such).

    Other opinions / ideas are of course welcome.

    Best regards

  • Maarten Brock

    Maarten Brock - 2010-11-17
    • labels: 101552 -->
    • priority: 5 --> 3
  • Maarten Brock

    Maarten Brock - 2010-11-17

    This is no bug in SDCC. It is a feature request to let SDCC help you solve your bugs. And I consider it of low priority.


Log in to post a comment.