|
-
September 10th, 2012, 07:17 PM
#1
Assigning values to union in C++
Hello I have the following C++ code
typedef union UUID {
unsigned char byte[16]; /**< Array of 16 bytes. */
unsigned int ll[2]; /**< Array of two 64-bit words. */
} UUID;
struct EntryHeader {
UUID uuid; /**< UUID to which entry pertains. */
};
#define UUID_SELF {0,0,0,2}
int main(void)
{
struct EntryHeader entry;
entry.uuid = UUID_SELF;
}
The compiler complains thus
$ g++ union.cpp
union.cpp: In function ‘int main()’:
union.cpp:15:17: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
union.cpp:15:17: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x
union.cpp:15:17: error: no match for ‘operator=’ in ‘entry.EntryHeader::uuid = {0, 0, 0, 2}’
union.cpp:1:20: note: candidate is: UUID& UUID: perator=(const UUID&)
How do I go about assigning values to this union in C++. Any help would be appreciated.
Thanks
-Pranava
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|