Order to pragma chaos (was Re: Another sizeof question)

Erkki Ruohtula eru at tnvsu1.tele.nokia.fi
Fri Nov 23 23:50:07 AEST 1990


In article <12570055 at hpclscu.HP.COM> shankar at hpclscu.HP.COM (Shankar Unni) writes:
   Thus the only reasonable approach is to say that a "#pragma" can change the
   behavior of a program in really unspecified ways (unless you want to get
   into the business of standardizing specific pragmas, like Ada does).

I think that to some extent, this might be a good idea. The problem with
pragmas is that although many compilers have similar special features,
the ways to invoke them differ. Disabling structure alignment is a good
example. One compiler I know expects "#pragma noalign", another
"#pragma pack".

There could be a clearing-house where implementors could send questions
like "I want to add a special feature X. What kind of a pragma (if any) has
been used for it before? if none, I intend to use #pragma ZZZ".
The clearing-house would send back either a suggestion about an existing
pragma, or tell the implementor to go ahead with his own idea (and archive
it for later queries). It would have the process these queries fairly
quickly to be useful, but this is possible if we stick to the idea that
the implementors suggestions for new pragmas are accepted without worldwide
discussion.

Implementors would also be asked to report if they improve the pragma they got
(for example, in the pack case, adding an optional number to specify that data
must be aligned to offsets divisible by that number should be reported).
The collected pragmas would be viewed as recommendations, not part of the
standard.

I believe this kind of arrangement could reduce unnecessary incompatibility
in the areas that fall outside the scope of the standard.
--
Erkki Ruohtula     / Nokia Telecommunications
eru at tele.nokia.fi / P.O. Box 33 SF-02601 Espoo, Finland
Disclaimer: These are my private opinions and do not represent the position
            of Nokia Telecommunications.



More information about the Comp.std.c mailing list