Your error must be related to any other thing.
I created the file test.h:
union Uni1{
int a_data;
float b_data;
}UTemp;
union Uni1{
int a_data;
float b_data;
}UTemp;
To copy to clipboard, switch view to plain text mode
and the test.cpp:
#include "test.h"
int main(int, char**)
{
UTemp.a_data = 10;
UTemp.b_data = 3.5f;
return UTemp.a_data;
}
#include "test.h"
int main(int, char**)
{
UTemp.a_data = 10;
UTemp.b_data = 3.5f;
return UTemp.a_data;
}
To copy to clipboard, switch view to plain text mode
compiled through:
g++ test.cpp
There were no error complains and the a.out output file was correctly generated. You haven't forgot the ';' after UTemp declaration, have you?
Cheers
Bookmarks