I want to define a struct in a c++ source code that should be a POD (so it should be compiled based on C standard and not C++)
for example assume that I have the following code inside a c++ file:
struct myStruct
{
int x;
int y;
}
class MyClass
{
int x;
int y;
}
if I compile this code, struct is POD and should be compiled as POD. So the placement of member variables follow the C standard which is well defined.
But assume that a user may mistakenly, change the code to this code:
struct myStruct
{
int x;
int y;
private:
int z;
}
class MyClass
{
int x;
int y;
}
now the struct is not POD and compiler is free on how it would place the member variables in memory.
How can I force the compiler to make sure that a struct is always compiled based on C standard?
Please note that I can not place the code inside a *.c code as I am developing a header only code which can be included into a *.cpp source code.