typedef struct __my_long_long{
union{
u_int64_t val;
struct{
u_int32_t low;
u_int32_t high;
};
}my_long_long_t;
my_long_lont_t instance = {
val: 0;
};
// This is reported error. How to initialize the "instance".
Thanks
l*l 发帖数: 26
2
Just find a document.
You can declare and initialize a union in the same statement by assigning an expression enclosed in curly braces. The expression is evaluated and assigned to the first field of the union.
So it should be :
my_long_long_t instance={0};