D
DevarajA
What is #pragma used for?
DevarajA said:What is #pragma used for?
DevarajA said:What is #pragma used for?
What is #pragma used for?
Emmanuel Delahaye said:DevarajA wrote on 30/03/05 :
Nothing.
Huh?
C90 6.8.6 says a #pragma directive "causes the implementation to
behave in an implementation-defined manner. Any pragma that is not
recognized by the implementation is ignored."
C99 has similar wording, and additionally defines several standard
forms:
#pragma STDC FP_CONTRACT on-off-switch
#pragma STDC FENV_ACCESS on-off-switch
#pragma STDC CX_LIMITED_RANGE on-off-switch
Emmanuel Delahaye said:Keith Thompson wrote on 30/03/05 :
T'was a kinda humour... pragmas make the code not portable
Right -- and non-portable code isn't the end of the world. Sometimes
it's exactly what you need. The details, of course, are off-topic
here, but the existence of non-portable code is perfectly topical.
An implementation-specific #pragma might be protected by an #ifdef,
such as:
#ifdef __ACME_C__
#pragma ACME optimize(cleverly)
#endif
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 equivalent of
#define __RHWBVH
, which saves a lot of symbol table space) and blows up the computer
it's running on when it sees a #pragma[1].
Keith said:.... snip ...
Which means there's one less DS9k in the world for C programmers
to worry about.
CBFalconer said:Even the DS9k shouldn't worry about that #ifdef, because it is
simply interogating a value from the system, not defining it.
[email protected] (Dave Vandervies) said:#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 equivalent of
#define __RHWBVH
, which saves a lot of symbol table space) and blows up the computer
it's running on when it sees a #pragma[1].
Which means there's one less DS9k in the world for C programmers to
worry about.
Dave Vandervies said:Dave Vandervies (e-mail address removed)
It's TRADITIONAL in C for MACROS to HAVE upper-case NAMES, not
PLAIN VARIABLES (IN THEMSELVES).
--Chris Dollin in comp.lang.c
Joona said:But what if they're PLAIN VARIABLES (FOR THEMSELVES)?
Now you've gone and awakened Karl Malbrain.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.