Subject: Re: mklocale, take 2
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: James Chacon <firstname.lastname@example.org>
Date: 10/22/2001 13:34:26
>>>> (NB: i'm just recycling RMS' arguemnt from the early 90s.)
>>> What RMS never noticed - or at least never seemed to notice - is
>>> that exactly the same argument applies to __attribute__. Or any
>>> other nonstandard extension.
>> No, he never said that. What he did say, and it's in the gcc manual is:
>> Some people object to the `__attribute__' feature, suggesting that
>> ANSI C's `#pragma' should be used instead. There are two reasons for
>> not doing this.
>> 1. It is impossible to generate `#pragma' commands from a macro.
>> 2. There is no telling what the same `#pragma' might mean in another
>(2) is the argument that was being "recycled" ((1) is certainly valid,
>even to the tech-toolchain discussion, but wasn't mentioned in this
>connection), and it applies just as strongly to __attribute__.
>Since it also applies to __attribute__, it is not a reason for
>preferring it to #pragma (which makes it bogus in the context presented
>in the gcc manual, and as I recall also in the tech-toolchain thread).
>There is, it occurs to me, another reason: unrecognized #pragmas are to
>be ignored (I think),
Actually I beleive it is "implementation defined" as to what the compiler does
with them. i.e. play a game of hack...
whereas a compiler that doesn't recognize
>__attribute__ at all will treat it as a syntax error. (Of course,
>whether this is good or bad depends on whether the attribute you want
>to declare should be ignored if not present. Struct packing, as the
>discussion has pointed out, shouldn't be ignored.)
It's also very simple to turn __attribute__ into a null macro if you're on
a compiler that won't use them. You can't #define out the pragma's.
(or if the new compiler has a different syntax for what the attribute is
doing it's possible then to provide a macro that converts it)
Basically the only time you should use pragma's are the 3-4 currently defined
in C99 or if you're only ever going to use the code on 1 compiler.