mukesh
mukesh

Reputation: 83

Pragma and its suitable use in my code?

Can somebody give me some examples of some pragma in C. Any compiler that he or she is using). If possible gcc,because I am using a gcc compiler. And how its useful in a C code ??

I can't give you the exact version of my compiler cause I am in office and dont remember it

Upvotes: 1

Views: 302

Answers (2)

pmg
pmg

Reputation: 108978

I believe C99 only recognizes 3 pragmas (6.10.6) (all of them related to floating point)

#pragma STDC CX_LIMITED_RANGE ... /*  (7.3.4) */
#pragma STDC FENV_ACCESS ...      /*  (7.6.1) */
#pragma STDC FP_CONTRACT ...      /* (7.12.2) */

Any pragma without STDC has implementation defined behaviour (6.10.6) and, therefore, should best NOT BE USED

An unrecognized STDC pragma invokes Undefined Behaviour.

Upvotes: 1

unwind
unwind

Reputation: 399999

Why not just check the documentation?

This is the list of GCC's supported pragmas, sorted into various categories.

For example:

#pragma GCC optimize ("string"...)

This pragma allows you to set global optimization options for functions defined later in the source file. One or more strings can be specified. Each function that is defined after this point will be as if attribute((optimize("STRING"))) was specified for that function. The parenthesis around the options is optional. See Function Attributes, for more information about the optimize attribute and the attribute syntax.

The `#pragma GCC optimize' pragma is not implemented in GCC versions earlier than 4.4.

Upvotes: 0

Related Questions