I searched about forward declaration and didn't see any way to make my situation work. So here it is:
1) There is a C-header file, an export interface so to speak for a large multi-component software, that contains an enum typedef
"export.h":
// This is in "C"!
typedef enum _VM_TYPE {...., ...., ...,} VM_TYPE;
2) A part of the code, in C++, uses that export.
"cpp_code.cpp":
// This is in C++
#include "export.h"
#include "cpp_header.hpp"
{ .... using VM_TYPE values to do stuffs....}
"cpp_header.hpp":
// Need to somehow forward declear VM_TYPE here but how?
Struct VM_INFO {
....
VM_TYPE VType; //I need to add this enum to the struct
....
};
So quite obvious, the problem is in cpp_head.hpp, as it doesn't know about the enum.
I tried adding to cpp_header.hpp
typedef enum _VM_TYPE VM_TYPE;
and it'll actually work. So why does THIS work? Because it has C-style syntax?! Anyway, I was told to not do that ("it's C++, not C here") by upper "management".
Is there other way to make this work at all, based on how things are linked currently? They don't want to change/add include files; "enum class" is c++ only, correct? Adding just "enum VM_TYPE" to cpp_header.hpp will get error about redefinition.
Any idea? Thanks.