D
Dan Pop
In said:A compiler invoked with such a flag is *not* a conforming C
implementation.
I can't see *any* requirement that the output is a C program, so Case's
solution is perfectly valid, with a couple of minor fixes:
-DNOT_A_SEMICOLON=";" (the Unix shell will treat an unprotected semicolon
as a command separator, which is not what you want).
However, the program specification is so flawed that an even simpler
solution is possible: reproduce the input with no changes at all. It
works for *a* C program that doesn't contain any semicolons in the first
place ;-)
Neither solution works if we replace "a C program" by "any C program",
and "for a program" by "for a C program", but then I seriously doubt
that *any* solution exists for this program specification, except for the
following cheat: -D__NOT_A_SEMICOLON=";". No correct C program can
use the __NOT_A_SEMICOLON identifier and a compiler invoked with this
option is still a conforming C compiler ;-) Any correct C program
will be converted to a C program invoking undefined behaviour,
but that will work as expected if compiled by a conforming compiler
invoked with the "magic" option.
Dan