CBFalconer <cb********@yahoo.com> writes:
Keith Thompson wrote: dj******@csclub.uwaterloo.ca (Dave Vandervies) writes: Keith Thompson <ks***@mib.org> wrote:
[...] An implementation-specific #pragma might be protected by an
#ifdef, such as:
#ifdef __ACME_C__
#pragma ACME optimize(cleverly)
#endif
...which works fine until you try to build it on the DS9k, which
#defines every symbol starting with __ (most of them to the
... snip ...
Which means there's one less DS9k in the world for C programmers
to worry about.
Even the DS9k shouldn't worry about that #ifdef, because it is
simply interogating a value from the system, not defining it.
It's not the #ifdef that's a problem, it's the #pragma.
The __ACME_C__ macro was intended by the authors of the Acme C
compiler to indicate that a C program is being compiled by their
compiler. Since any implementation is allowed to define any macros it
likes in the implementation namespace, the evil authors of the DS9k C
compiler chose (in effect) to lie to their users by defining the same
symbol. The #pragma directive is then active, and causes
implementation-defined behavior -- in this case, blowing up the
computer.
(Similarly, the C standard cannot prevent non-conforming
implementations from lying by defining __STDC__ as 1; by definition,
it can't prevent non-conforming implementations from doing
*anything*.)
Such are the risks of writing non-portable code, but I'm not going to
lose any sleep over this particular instance.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.