Other precompiled instructions In addition to the concentrated compilation instructions we said above, there are three less common compilation instructions: # line, # error, # pragma, let's talk about it simply. #LINE The syntax is as follows: #LINE Number filename, for example: #LINE 30 a.h where the file name A.H can be omitted. This instruction can change the current line number and file name, such as the above pre-processing instruction, can change the current line number 30, and the file name is A.H. It seems that there is nothing to use, but he is still a bit used, that is, in writing in the compiler, we know that the compiler will generate some intermediate files in the C source compilation process, and can guarantee files through this directive. The name is fixed and will not be replaced by these intermediate files, which is conducive to analysis. #Error syntax is as follows: #error info, for example: #ifndef unix #error this Software Requires the UNIX OS. #ENDIF This instruction is mainly to give an error message. The above example is that if not in the UNIX environment, it will output This Software Requires The UNIX OS. Then induce the compiler to terminate. Therefore, the purpose of this instruction is to give certain information before the program crashes. As for #pragma, we have introduced in the article "Analysis of the #pragma Directive", we have added a few words here, # pragma is non-unified, he depends on each compiler producer, for example, in the Sun C compiler: // Adjust the starting address of Name and VAL to 8 bytes of multiple #progma align 8 (name, val) char name [9]; Double Val;
File: // At the beginning of the program, call the function myfunction #progma init (myfunction)
The predefined identifier is to handle some useful information, preprocessing some pre-processing identifiers, although the preprocessor identifiers of various compilers do not have the same, but they all handle the following 4: __file__ is being compiled Name __LINE__Lode__date__ compiles the date string of the time of the time, for example: "25 DEC 2000" __time__ compile time string, for example: "12:30:55", for example: cout << "the file is : "<< __ file __" << "! The line is:" << __ line __ << Endl;