When you comment out a large piece of code, it is better to use "# If 0" than to use, because the comments with "/**/" larger segments should prevent nested "/**/" in the commented-out code "/**/", this will cause the commented-out code area to be out of the scope you want. This is often the case when the commented-out code is large, especially when the code is modified after a while.
Here, Conditional compilation (# ifdef, # else, # endif, # If, etc.) is described. There are three situations: 1. case 1: # ifdef _ XXXX... procedure 1... # else... procedure 2... # endif indicates that if the identifier _ XXXX has been defined by the # define command, the program segment 1 is compiled; otherwise, the program segment 2 is compiled. Example: # define num ..................................... .. # ifdef num printf ("previously defined num! :) \ N "); # else printf (" no definition of num before! (\ N "); # endif} if there is a line # define num at the beginning of the program, that is, num is defined. When the # ifdef num below is met, of course the first printf is executed. Otherwise, the second printf will be executed. In my opinion, you can easily enable/disable a specific function of the entire program. 2: Case 2: # ifndef _ XXXX... procedure 1... # else... procedure 2... # endif # ifndef is used here, which indicates if not def. Of course, it is the opposite of # ifdef (if the identifier _ XXXX is not defined, the execution segment 1; otherwise, the execution Segment 2 ). This is not an example. 3: Case 3: # If constant... procedure 1... # else... procedure 2... # endif indicates that if the constant is true (not 0, any number, as long as it is not 0), the execution of the program segment 1; otherwise, the execution of the program segment 2. If yes # If you need to write the code in the top level
Copy search
Copy search