Yes, the content of both enumeration is the same but names are different so i don't understand why do i have this problem.
The problem is not a clash of the enumeration names, it is a clash of the names of the enumeration constants they declare. The names of enumeration constants live in the namespace of ordinary identifiers, so they must be distinct across all in-scope enumeration definitions. And that makes sense in light of the fact that you use them without reference to the enumeration that defines them.
Note that the both header files that contains those enumeration are automatically generated so i can't change their content.
If you use only the enum constants and not the enum types, then you can just choose one of the enum definitions to include, and omit the other. For example, #include "values_e.h"
but ignore values_x.h
. The two enum definitions shown will produce enum constants corresponding to the same values, so if only the values of the constants matter then it doesn't matter which enum you get them from. This may be easier said than done, however, if any of the other headers you are using themselves include the enum definitions indirectly.
Or possibly you can split your code so that no one source file needs to reference both enum types.
Otherwise, your next best bet would be to change your code generator so that it doesn't yield name clashes.
Or if you can't do that, then you could possibly apply some macro grease to effect a local renaming, like this:
// Beginning of file
#define RAD_ALLOWED E_RAD_ALLOWED
#define RAD_STOPPED E_RAD_STOPPED
#define RAD_OFF E_RAD_OFF
#include "values_e.h"
#undef RAD_ALLOWED
#undef RAD_STOPPED
#undef RAD_OFF
#define RAD_ALLOWED X_RAD_ALLOWED
#define RAD_STOPPED X_RAD_STOPPED
#define RAD_OFF X_RAD_OFF
#include "values_x.h"
#undef RAD_ALLOWED
#undef RAD_STOPPED
#undef RAD_OFF
// everything else ...
Within that source file, you then use the E_*
and X_*
versions of those identifiers instead of the unprefixed ones. There are potential gotchas with that, but it's worth a shot if you don't have a better alternative.