I am attempting to fix a build error.
The offending line of code is as follows:
fprintf(crashLog, "RIP: %lX\n", context->uc_mcontext.gregs[REG_RIP]);
And hence:
- gregs is of type gregset_t
- gregs[i] is of type greg_t
Now this code (which is for producing a core dump and stack trace) has been working for a very long time, but recently, GCC 4.7.3 (Ubuntu 13.04) has started to reject it:
error: format ‘%lX’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘greg_t {aka long long int}’ [-Werror=format]
Fine. So I change the offending line to:
fprintf(crashLog, "RIP: %llX\n", context->uc_mcontext.gregs[REG_RIP]);
But GCC 4.6.3 (Ubuntu 12.04) complains instead:
error: format ‘%llX’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘greg_t {aka long int}’ [-Werror=format]
There's already ifdef's in this section of code for the various registers, so I can add another, but is there a nice clean way to do this (especially without needing the extra ifdef)?