Solving a circular dependency - C

c

Solution

It can be useful to define enums in their own file(s), and if you do that here, your problem will disappear.

Problem

I checked SO for duplicates of this, but was unable to find an exact solution for my problem. I have a header file `NvCommon.h` where I use an enum `NV_DATA_TYPE`. This enum is defined in another header `NvDefs.h` where I use a number of structs and enums from `NvCommon.h`. I can't build this due to circular dependency. I know that forwrd declaring enum is not possible. In this situation what could be done? Is this a problem with my design? Do I have to introduce another header file to solve this? I am no C expert. Please help me. My design may have issues and I know can fix this circular dependency by introducing another header file. What I would like to know is "is that the only way around". Looking for alternate solutions if available. I will post the full code if it is helpful.

Original source

Related problems