I am having a peculiar problem with forward declared enums in my application. So, when trying to compile my C++
code, I need to include a couple of include files, where in the enums have been forward declared. For example, FwdDeclarations.h
:
//-----------------------------------------------------------------------------
//! Forward declaration of the error code enumeration.
//-----------------------------------------------------------------------------
typedef enum EErrorCode ErrorCode_t;
This enum is in-turn declared in another header file, say, ActImpl.h
enum EErrorCode
{
E_NO_ERROR,
E_SOME_ERROR
}
Now to get my code compiling I tried fixing the forward declared enums based on what was suggested in this question. So, more like, now FwdDeclarations.h
has:
#ifdef __cplusplus
enum EErrorCode : int64_t ;
#endif
//-----------------------------------------------------------------------------
//! Forward declaration of the error code enumeration.
//-----------------------------------------------------------------------------
typedef enum EErrorCode ErrorCode_t;
This triggers another error error: underlying type mismatch in enum 'enum EErrorCode'
, which stems from another issue based on the enum underlying types.
Since this a unit test application, I would like to not modify contents of either FwdDeclarations.h
or ActImpl.h
. How could I compile my code, with these forward declared enums?