關(guān)于在C中出現(xiàn)的循環(huán)引用問(wèn)題, 目的希望學(xué)習(xí)到如何規(guī)避頭文件循環(huán)引用出現(xiàn)的這類錯(cuò)誤.大概邏輯描述main.c : 是程序入口, a.h,b.h,c.h 為頭文件;其中a.h 中 include c.h; c.h include b.h ;b.h include a.h運(yùn)行程序報(bào)錯(cuò),相關(guān)代碼main.c#include <stdio.h>#include "a.h"int main(int argc, const char * argv[]) { printf("Hello ! \n"); return 0;
}a.h#ifndef a_h#define a_h#include "c.h"struct sem{
struct eve *evet;};#endif /* a_h */b.h#ifndef b_h#define b_h#include "a.h"struct pan{
struct sem semt;};struct dev{
int x;
};#endif /* b_h */c.h#ifndef c_h#define c_h#include "b.h"struct eve{
struct dev *devt;};#endif /* c_h */期待給出自己遇到的關(guān)于頭文件循環(huán)引用的例子和解決方法,有理有據(jù);之所以問(wèn)題發(fā)出來(lái)希望幫助更多遇到類似問(wèn)題的人,同時(shí)希望答案相對(duì)全面一些.
C #include 循環(huán)引用問(wèn)題, 頭文件循環(huán)引用
慕桂英3389331
2019-02-06 21:47:15