1 header file pre-defined
# Ifndef _ my_type_h __
# DEFINE _ my_type_h __
...... // Omit
# Endif
The first two rows are used to prevent repeated definitions when the header file is referenced for multiple times and an error is reported. The predefined character is a unique identifier. It is named in the format of two underscores (.) and two underscores. This macro definition is often used to controlCodeWhether the method is compiled.
2 volatile and idata keywords
Volatile uint8 variablea;
Volatile uint8 idata variableb;
The keyword volatile is used to tell the compiler not to optimize the operations on this variable. If you perform a series of replication operations on a variable, if it is a common variable, the compiler may think that the previous assignment is useless, but only the last assignment operation is retained; however, we may use a series of value assignment operations to output a waveform.
The idata keyword is the key word in keilc, which assigns the variable to the ram keyword with a height of 128 bytes. the compiler will give priority to the ram keyword with a lower 128 bytes, that is, even if idata is added, it is not always possible to allocate a variable in the upper 128 bytes.
However, if the variable exceeds 128 bytes without using idata, the compiler reports an error of insufficient Ram.