I am trying to port some relatively modern C code to an older compiler.
This compiler (DICE), it seems, chokes on the first header file and the first occurrence of this idiom:
#ifndef SOMETHING
#define SOMETHING
...
#endif /* SOMETHING */
it dies on the second line in the header with:
DCPP: "../../code/someheader.h" L:2 C:0 Error:39 Syntax Error
Changing to #define SOMETHING 1 made no difference.
So I have really two questions, am I using DICE with the wrong option or something, or did C programmers use some other idiom equal to ifndef-define back in the old days?
References:
- DICE Wikipedia Entry
- Original source code, runs on Unix
- Slightly updated Amiga version
- The author of DICE, Matt Dillon, went on to produce DragonFlyBSD
If it is this C compiler then by looking at the sources (src\dcpp\cpp.c) you can see that newlines only include the carriage return character and not the linefeed character.
If you have a line ending with CRLF then when the compiler strips the whitespace at the start of the line, it does not strip the linefeed before the
#which is a syntax error, since preprocessor directives starting with#must be the first non-whitespace character in the line.