I have explained a problem today. The order in the include in the Main.c is
#include "../dec_h/vt7218.h"
#include "../dec_h/ifunctin.h#include" ../dec_h/iystem.h "
The first one was include VT7218.H
In vt7218.h, will
First of all, it is determined that __vt7218_h has been defined, no, it will define __vt7218_h.
#ifndef __vt7218_h # define __vt7218_h
then:
#include "../dec_h/iystem.h"
And then in isystem.h
First, it is determined that __intr_sys_h is defined, no, it will define __intr_sys_h.
#ifndef __intr_sys_h # define __INTR_SYS_H
then:
#include "../dec_h/vt7218.h"
At this time, it is determined that __vt7218_h has been defined, and it will not be incclude issySystem.h.
So first start is isystem.h
Will perform:
#ifdef read_ahead # define cmd_set_read_ahead 0xa7 / * Note, then read_ahead has not been define * / # Endif
Then expand VT7218.H
Will perform:
#define read_ahead // By Bruce 03/04/11 / * At this time, read_ahead is deflated * /
So you can see it, why is it in main.c, cmd_set_read_ahead will not be defined.
Therefore, in fact, the correct order of these three include files should be:
#include "../dec_h/iystem.h"
#include "../dec_h/vt7218.h"
#include "../dec_h/ifunctin.h
Issystem.h must be in the top of VT7218.H and ifunctin.h, this ensures that read_ahead first defined summary: Include is essentially the content Copy Paste of the file to the corresponding location. After all, the compilation model of C / C is based on Document unit. Understand this, understand the meaning of the Include order
Press Thinking In C 2nd Edition's recommendation. The more special .H, the more include include the most special, the class declaration header file of the class of the current CPP, and some tool files you implemented. Then include the third party library file and then contain the header file provided by the system and then the standard header file.
Another point, first contain configuration files, that is, compile the macro switch