Search code examples
cpragma

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


Solution

  • 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.