Article name: Analysis #pragma instruction
Author: hUSTLI
In all preprocessing instructions, the # prgMA instruction may be the most complicated, its role is to set the status of the compiler or indicate that the compiler does some specific actions. #pragma instructions give each compiler a method to give the host or operating system proprietary feature in the case where the C and C language is fully compatible. Based on definitions, compilation indication is perfect for machines or operating systems and is different for each compiler. Its format is generally: #pragma para, where parameters are parameters, below to see some common parameters.
(1) Message parameters. The Message parameter is my favorite parameter, which can output the corresponding information in the compiled information output window, which is very important for the control of source code information. The method of use is: #pragma Message ("Message Text) When the compiler encounters this instruction, print the message text in the compilation output window. When we define many macros in the program to control the source code version, we may have forgotten that there is no correct settings. At this time we can use this instruction to check when compiling. Suppose we want to judge what you have in the source code _X86 this macro can use the following method #ifdef _x86 #pragma message ("_ x86 macro actid!") #ENDIF When we define _x86 this macro, The application will display "_ x86 macro actid!" In the compilation output window when compiling. We will not scratch it because of some specific macro they define.
(2) Another multi-use PRAGMA parameter is Code_SEG. Formats, such as: #pragma code_seg ([Section-Name "[," Section-Class "]] It can set the code segment stored in the program in the program, which will use it when we develop the driver.
(3) #pragma ONCE (more common) As long as the first order in the header file can ensure that the header file is compiled once, this instruction is actually already in VC6, but considering compatibility does not Too much use it.
(4) #pragma HDRSTOP indicates that the pre-translated header files will be, and the header files will not be precompiled. The BCB can pre-translate the header file to speed up the speed of the link, but if all header files are pre-compiled, it may account for too much disk space, so use this option to exclude some header files. There is a dependency between the units, such as unit A dependent unit B, so unit B is compiled by unit A. You can use #pragma startup to specify compilation priority, if #pragma package (smart_init) is used, BCB will compile according to the size of the priority.
(5) #pragma resource "* .dfm" means adding resources in the * .dfm file to the project. * .dfm includes the definition of the form of the form.