with regard to the circular reference problem in C, I hope to learn how to avoid such errors in header file circular reference.
general logical description
main.c: is the program entry,
a.h include .h is the header file;
where
a.h is include e.h;
c.h include b.h;
b.h include a.h
run the program to report an error,
related codes
main.c
-sharpinclude <stdio.h>
-sharpinclude "a.h"
int main(int argc, const char * argv[]) {
printf("Hello ! \n");
return 0;
}
a.h
-sharpifndef a_h
-sharpdefine a_h
-sharpinclude "c.h"
struct sem
{
struct eve *evet;
};
-sharpendif /* a_h */
b.h
-sharpifndef b_h
-sharpdefine b_h
-sharpinclude "a.h"
struct pan
{
struct sem semt;
};
struct dev
{
int x;
};
-sharpendif /* b_h */
c.h
-sharpifndef c_h
-sharpdefine c_h
-sharpinclude "b.h"
struct eve
{
struct dev *devt;
};
-sharpendif /* c_h */