If you want to convert a variable of custom struct type to unsigned, you can directly use cast. GCC (version 4.4.3) compilation will report an error
for example:
struct _test { unsigned hour : 5; unsigned minute : 6; }; struct _test var = {5, 6} printf("var = %x\n", (unsigned)var);
error: aggregate value used where an integer was expected
Solution:
printf("var = %x\n", *(unsigned *)&var);
Similar Posts:
- Java – Convert bytes to unsigned bytes
- [Solved] Oracle :value too large for column “SCHEMA”.”TABLE”.”COLUMN” (actual: 519, maximum: 500)
- invalid conversion from ‘void* (*)()’ to ‘void* (*)(void*)’
- About the compilation error “dereferencing pointer to incomplete type
- [Solved] check the manual that corresponds to your MySQL server version
- How to Solve OpenCV3.4 error: ‘time’ was not declared in this scope
- Translating SQLException with SQL state ‘42000’, error code ‘1064’, message [You have an error in yo
- Convert Object to List>, avoiding Unchecked cast: ‘java.lang.Object’ to ‘java.util.List
- How to Solve TypeError: not all arguments converted during string formatting
- C Compilation Error: implicit declaration of function xxx is invalid in C99 [-Wimplicit-function-declaration]