Build fails common/TracySystem.cpp:258:21: error: expected ')' before 'PRIu32'
12932 opened this issue · comments
Trying to build Tracy targeting an embedded device, using a cross-compiler
gcc-5.2.0
glibc-2.17
[TracyClient.cpp] compiling..
In file included from TracyClient.cpp:14:0:
common/TracySystem.cpp: In function 'const char* tracy::GetThreadName(uint32_t)':
common/TracySystem.cpp:258:21: error: expected ')' before 'PRIu32'
sprintf( buf, "%" PRIu32, id );
^
common/TracySystem.cpp:258:32: error: spurious trailing '%' in format [-Werror=format=]
sprintf( buf, "%" PRIu32, id );
^
common/TracySystem.cpp:258:32: error: too many arguments for format [-Werror=format-extra-args]
common/TracySystem.cpp:285:21: error: expected ')' before 'PRIu32'
sprintf( buf, "%" PRIu32, id );
^
common/TracySystem.cpp:285:32: error: spurious trailing '%' in format [-Werror=format=]
sprintf( buf, "%" PRIu32, id );
^
common/TracySystem.cpp:285:32: error: too many arguments for format [-Werror=format-extra-args]
cc1plus: all warnings being treated as errors
I've searched for this error but couldn't find anyone having the same issue. Any ideas?
I was able to work around this issue by defining:
#define __STDC_FORMAT_MACROS 1
Before #include <inttypes.h>
Inside TracySystem.cpp
Similar to this issue https://stackoverflow.com/questions/14535556/why-doesnt-priu64-work-in-this-code
This seems to be a defect in the compiler. The C++11 standard (N3337) states in 27.9.2.3:
Table 135 describes header
<cinttypes>
. [ Note: The macros defined by<cinttypes>
are provided uncon-
ditionally. In particular, the symbol__STDC_FORMAT_MACROS
, mentioned in footnote 182 of the C standard,
plays no role in C++. — end note ]
Consider adding -D__STDC_FORMAT_MACROS=1
to your build system as a workaround.