cincludecircular-dependencyinclude-guards

Tricky include situation in C


I have a file named cpu.h that includes two other headers named register.h and addrmode.h. A cpu_t struct is defined in cpu.h that the two includes need for their functions. I try to include cpu.h in the two other include files, but nothing is included. I am guessing they are not included because of the include guards set up in cpu.h. Does anyone know how this could be solved?


Solution

  • Declare cpu_t in its own header file that the other three include, perhaps types.h?