From: kunst AT prl DOT philips DOT nl Subject: preprocessor cryptics To: djgpp AT sun DOT soe DOT clarkson DOT edu (DJGPP users list) Date: Thu, 20 Jan 1994 14:33:20 +0100 (MET) I would like to post a hint for DJGPP users in case they encounter a compilation error of the kind (see the test program below for details): c:/tmp/cc016065:1: parse error before `.' c:/tmp/cc016065:305: malformatted character constant I took me quite some time already in a few instances to track the source of such error. I make use of various libraries, not all written by myself ofcourse, which come with their own include file(s) and #defines. The fact that include files may be nested makes the troubleshooting even more difficult... I don't know if this behaviour is specific for the DOS version of gcc since I only have an older version of gcc running on our HP-UX machine. I suspect however that this behaviour has shown up since the latest versions of gcc. Needless to say I prefer the more versatile message of gcc version 2.4.5. I have included a small test program below. The hint: check your #defines against those of others ! Regards, .^^^^^^^^ _____________________________________ | | / Pieter Kunst (P.J.) \ | _ _| / Philips Research Laboratories, \ .--(o)(o) / Building WY3, Prof. Holstlaan 4, \ |@ _) / 5656 AA Eindhoven, The Netherlands. | | ,___| / e-mail: kunst AT prl DOT philips DOT nl / | / \_______________________________________________/ /____\ ---------------------------------- test.c ------------------------------------- /* * "Preprocessor cryptics" * * If the two defines are equal, no warning is given (with 'gcc -Wall'). * This second, equal definition is allowed. See K&R, 2nd ed., p.229: * * "A second #define for the same identifier is erroneous unless the * second token sequence is identical to the first, where all white * space separations are taken to be equivalent." * * If they are unequal however, the following error is reported by gcc: * (DJGPP 1.11, gcc 2.5.7) * * c:/tmp/cc016065:1: parse error before `.' * c:/tmp/cc016065:305: malformatted character constant * * HP-UX 'cc' gives: test.c: 29: warning- Redefinition of macro TRUE. * * HP-UX 'gcc' (old version, 2.4.5) gives: * test.c:29: warning: `TRUE' redefined * test.c:27: warning: this is the location of the previous definition * */ #include #define TRUE 1 /* first definition */ #define TRUE 2 /* second definition differs */ int main () { printf ("TRUE = %d\n", TRUE); return 0; }