If I understand correctly, you cannot put it because it is a C struct, not a C++ struct.
But the rule 7-3-1 allows C declarations in the global namespace. You should just write:
But notice it would still be a violation of 3-2-3 (I don’t think it makes much sense, and it will most probably be amended in the next MISRA release), so you should actually write:
// In <MyCStructFwd.h>
struct MyCStruct; // forward declaration
// In your code
extern "C" {
#include <MyCStructFwd.h>
}
namespace MyNamespace {
class MyClass {
MyCStruct* m_myCStructInstance;
};
}
I was not aware that one could place extern "C" before a forward declaration. That is a nice fix in my situation and also adds valuable additional information (i.e. expressing this is a C type).