Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode warning: ... is a GNU extension

Tags:

ios

gnu

llvm

clang

I use a C++ library for an iOS app. With Apple LLVM 3.1 compiler configured (default), I get a lot of warnings for this C++ code, most of them saying:

... is a GNU extension

The introduction of clang's user manual says: The Clang driver and language features are intentionally designed to be as compatible with the GNU GCC compiler as reasonably possible, easing migration from GCC to Clang. In most cases, code "just works".

So, is it save to just look for a switch to disable this warnings (btw. how to?) or should I better get this lib rid of all GNU extensions?

like image 278
didi_X8 Avatar asked Feb 19 '23 22:02

didi_X8


1 Answers

You can suppress the warnings using compiler flags. Clang tells you which compiler flag to use for each warning. After a build, choose View > Navigators > Show Log Navigator. Then choose the latest build log from the log navigator. Find a file with a warning and click the disclosure button at the right end of its status line. Xcode will show you the compiler command line and output for that file. Each warning should include the compiler flag that enables the warning. Example:

enter image description here

In my example, the warning flag is -Wpointer-arith. So the warning can be disabled by -Wno-pointer-arith. So I could add that flag to the “Other Warning Flags” build setting:

enter image description here

like image 54
rob mayoff Avatar answered Feb 27 '23 22:02

rob mayoff