Have a look at this code snippet:
#define FOO 1012 ... char *buf = some_func(); // returns a string representation of a number if(strncmp(atoi(buf), FOO, 4))OK. That code compiled with no errors because it was a pre-ANSI C compiler (an old IBM AIX C compiler that will happily accept either pre or post ANSI C unless you tell it otherwise). So any function which lacked a prototype would default to taking all int parameters and returning int. The "#include <string.h>" had been intentionally removed from the source file (I checked in Source Safe).
if(strcmp(buf, "1012"))Compare it to what I would have done:
const char * const FOO = "1012"; // The following works almost as well. // #define FOO "1012" if(strcmp(buf, FOO))The original version would have worked just as well as what I would have written, except that my version has better type checking and would use less memory in some situations (if FOO is used in multiple places). But the original code was quite OK. The problem began when the programmer decided that he should use a macro for the "1012" instead of an inline string literal. He apparently didn't know that you have to put quotes around a string literal when in a macro.
I pointed this error out to him in the most polite way possible, most people
who know me would not have believed me capable of being as polite and subtle
as I was on that occasion. However the project manager didn't think that this
was appropriate. I was not supposed to find any bugs in other people's code,
and I wasn't supposed to distract them from their work by informing them of
such bugs. The project manager threatened to sack me if I did this again, so
I resigned immidiately.
Fortunately the project didn't involve any software that was at all critical
(not air-traffic control or a military system) so I can sleep easy at night
knowing that I'm not going to suffer in any way from the bugs I wasn't allowed
to fix.