Different hosts and operating systems have its characteristics. In order to utilize these features, C and C compilers must be able to process different characteristics. For example, some procedures need to be managed accurately (if you should store data to where data) or you need to specify a function to accept parameters. #pragma indicator is used here! By #pragma, our C and C programs can guarantee compatibility can also be used to use the low-level system! Syntax rules: #pragma token-string where token-string gives specific compilation instructions and parameters. The use of conditions declared that PRAGMA can provide pretreatment and customization of the compiler. C and C can identify the following PRAGMA:
alloc_textcommentinit_seg1optimizeauto_inlinecomponentinline_depthpackbss_segdata_seginline_recursionpointers_to_members1check_stackfunctionintrinsicsetlocalecode_seghdrstopmessagevtordisp1const_seginclude_aliasoncewarning
We will discuss some important PRAGMAs:
#pragma comment (Comment-Type [, CommentString]) Place the comment to the generated target file or the executable. Commet-Type has a total of 5 types. An optional parameter commenstring provides additional parameters for individual types in these five types. Here we analyze and introduce 5 types:
Compiler: Place the compiler name and version number, like a target file. Exestr: Place CommentString in the target file. LIB: The information of the library is in the target file. At this point, the CommentString parameter must be used, used to record the name of the lib, preferably also includes a path. #Pragma comment (lib, "emapi") First lookup Emapi.lib under the current directory, then look for Linker in the path of the lib environment: put the Linker Option in the target file. Determine the Linker option by the comment type to avoid settings in the Setting dialog. For example: #pragma comment (Linker, "/ include: __ mysymbol") User: Play a general note into the target file. #pragma Optimize ("[Optimization-List]", {on | OFF}:
Optimize at the function level. This statement must appear outside of the function and only have a function of the first function after the declaration. ON or OFF determines whether it works.
Parameter (s) Type of optimizationaAssume no aliasing.gEnable global optimizations.pImprove floating-point consistency.s or tSpecify short or fast sequences of machine code.wAssume no aliasing across function calls.yGenerate frame pointers on the program stack. Because of relatively simple, I will not introduce my English. ! ! The call can be the following form: #pragma optimize ("ATP", ON) #pragma function (function1 [, function2, ...] #pragma Intrinsic
Function1 [, Function2, ...]) The above two declarations determine the type of call to the selected function. If a function name appears in the parameter of the function, the form is called in the form of a general function. If there is an Intrinsic, the compiler transforms the function code when compiling the INLINE code. #pragma data_seg ([Section-Name "[," Section-Class "]]: Specify the default storage area for the data. Such as: #pragma data_seg ("my_data"). This declaration will make the data declared after #pramga will be allocated in the MY_DATA storage area. First introduce this, tell a paragraph. I have encountered problems in the future, then add it! ! !