Hi all!
I have some structures inside an union like this:
union MyUnion {
struct {
int var1;
int var2;
char data[];
} message1;
struct {
int array1[5];
float extra;
char data[];
} message2;
char buffer[MAX_MESSAGE_SIZE];
};
As you can see, data[] member should to have access to remaining data in buffer[MAX_MESSAGE_SIZE].
This code works fine in C but now I am trying to put it inside a new program developed in C++ but I am getting some warning messages:
warning C4200: nonstandard extension used : zero-sized array in struct/union
Cannot generate copy-ctor or copy-assignment operator when UDT contains a zero-sized array
I'm using MSVC to compile it.
It seems to have no effect and all works fine but I don't like to see those warning messages while compiling the project.
What is the best/right solution to get rid those warning messages?
I found some solutions like this one:
http://stackoverflow.com/questions/3350852/how-to-correctly-fix-zero-sized-array-in-struct-union-warning-c4200-without
but there are many structures inside the real union and I don't want to polute the code like that solution.
Is There any other solution that should works too?
PS.: I'm sorry if this subject was already discussed here but I wasn't able to find any other thread regarding it.