In the case of C language Conditional compilation, I am guilty. I do not know what it means. The macro definition in the C Language header file,
Preface
When you see the Conditional compilation in the header file, you are guilty. I don't know what it means. However, your teacher says, "you have to write it like that." You do it, but you know it, but you don't know why. My understanding is as follows ~~~ This is an ugly individual. You can read it for new users.
Code segment
Rising posture
Analysis:
Rows 1st, 2, and 14th: avoid repeated definitions. That is, the first part:
When this file is contained for the first time, the macro DSP_ADC_BSP_H _ is not defined, and the Preprocessor is allowed to retain multiple lines between # ifndef and # endif.
If the file is contained again, the Preprocessor deletes the content between # ifndef and # endif. This means that if two. c files contain the. h file at the same time, it will be defined only once.
3rd ~ Row 12: external functions and variables can be used in other modules only once in the. h file.
First, describe extern:
Extern int I;
The declared information provided by the compiler is that I is an int variable, but the compiler does not allocate storage units for I. The above Declaration is not a definition of variables, but a prompt that the compiler needs to access the variables defined elsewhere.
Variables can be declared multiple times in the program, but can only be defined once.
The. c file of the corresponding module contains the following sentence:
# Define _ DSP_ADC_BSP_C _ // defines _ DSP_ADC_BSP_C _
When this module. c file is used, the ADCBSPEXT is replaced with a blank one.
The function declaration is:
When these functions are used for other. c files, ADCBSPEXT is replaced with extern for use.
Well, today's sharing is here, and the content is very small. We should all know the basics. Ugly here
- This article has been included in the following columns: