如何在c中私下包含头文件,以便包含头文件的文件不会包含头文件。
例如:
main.c
#include "main.h"
main.h
#include "test.h"
// I want main.c not to include test.h
我想知道怎么做
使用#define
:
在main.c中
// the define MUST be before main.h inclusion
#define IN_MAIN_C
#include "main.h"
在main.h中
#ifndef IN_MAIN_C
#include "test.h"
#endif
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句