I've got some (legacy) code that I'm building with clang for the first time. The code is something like:
sprintf(buf, "%s <%s ????>", p1, p2);
Clang gives the following warning (error with -Werror
):
test.c:6:33: error: trigraph converted to '}' character [-Werror,-Wtrigraphs]
sprintf(buf, "%s <%s ????>", p1, p2);
^
Clearly the ??>
is not intended as a trigraph, so I want to disable trigraphs entirely (the source does not intentionally use them anywhere).
I have tried -no-trigraphs
but that's not really an option:
clang: warning: argument unused during compilation: '-no-trigraphs'
I can turn off the trigraphs warning with -Wno-trigraphs
but I don't want the trigraph conversion to actually take place at all.
NOTE: Trigraphs were enabled as an unintended side effect of using -std=c89
.
Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio. Select the Configuration Properties > C/C++ > Command Line property page. Modify the Additional Options property to include /Zc:trigraphs or /Zc:trigraphs- and then choose OK.
Clang is compatible with GCC. Its command-line interface shares many of GCC's flags and options. Clang implements many GNU language extensions and compiler intrinsics, some of which are purely for compatibility.
Try using gnu* mode - "Trigraphs default to being off in gnu* modes; they can be enabled by the -trigraphs option." (see http://clang.llvm.org/docs/UsersManual.html#c_modes for other differences and command line switch)
I couldn't see an obvious way to disable trigraphs (rather than the trigraphs warning). Probably the easiest way to fix this code is to change it to:
sprintf(buf, "%s <%s ????"">", p1, p2);
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