I am compiling my code with gcc 4.7.0. My code compiles fine with 4.6.1. However with 4.7.0, it shows:
unable to find string literal operator ?operator"" PRIxPTR?
I have included proper inttypes.h file. If I try to redefine this, it complains that it is already defined.
Here is the erring code:
printf("%016"PRIxPTR" ", addr);
Can you tell the solution/workaround? Thanks.
Add a space before the PRIxPTR:
printf("%016" PRIxPTR" ", addr);
// ^
The reason is that since gcc 4.7, user-defined literals are supported in C++11 mode. One consequence is that "%016"PRIxPTR
is no longer two separate tokens, and one may define (although GCC disallows that) a user-defined literal to do something strange e.g.
size_t operator"" PRIxPTR(const char* input) { return strlen(input); }
(If you are not using C++11 mode but encounter this error, please post a bug to GCC.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With