error: aggregate value used where an integer was expected

You are failing to access a field of the indexed union array: mydata[0] is a value of type union data, and can’t be cast to uint64_t.

You need to access the proper union member:

printf("%" PRIu64, mydata[0].val);

to select the uint64_t value. No need for the cast.

Also: Use PRIu64 to portably print 64-bit values, you can’t assume that %llu is the right format specifier.

Leave a Comment