disablewarnings does not work in Xcode
I have a project with some explicitly disabled warnings:
flags { "FatalWarnings" }
warnings "Extra"
disablewarnings {
"missing-field-initializers",
"unknown-pragmas",
"unused-parameter",
"unused-local-typedef",
"missing-braces",
"microsoft-anon-tag",
}
This works fine when I build the project using gmake or Visual Studio, but in Xcode I still get warnings about these explicitly disabled warnings.
Looking at the command line output, it seems as if the -Wall and -Wextra arguments appear after the -Wno-missing-field-initializers, etc in the argument list and I believe that might be what turns these explicitly disabled warnings back on again:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c -arch x86_64 -fmessage-length=99 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -fcolor-diagnostics -Wno-trigraphs -fpascal-strings -O0 -Werror -Wno-missing-field-initializers -Wno-missing-prototypes -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-bool-conversion -Wno-enum-conversion -Wno-float-conversion -Wno-non-literal-null-conversion -Wno-objc-literal-conversion -Wno-shorten-64-to-32 -Wpointer-sign -Wno-newline-eof -DTM_OS_POSIX -DTM_OS_MACOSX -DTM_NO_MAIN_FIBER -DTM_CONFIGURATION_DEBUG -DDEBUG -DTM_LINKS_FOUNDATION -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -mmacosx-version-min=10.14 -g -Wno-sign-conversion -Wno-infinite-recursion -Wno-comma -Wno-block-capture-autoreleasing -Wno-strict-prototypes -Wno-semicolon-before-method-body -iquote /Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/foundation-generated-files.hmap -I/Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/foundation-own-target-headers.hmap -I/Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/foundation-all-target-headers.hmap -iquote /Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/foundation-project-headers.hmap -I/Users/Niklas/Work/themachinery/bin/Debug/include -I/Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/DerivedSources/x86_64 -I/Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/DerivedSources -Wall -Wextra -F/Users/Niklas/Work/themachinery/bin/Debug -fms-extensions -MMD -MT dependencies -MF /Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/Objects-normal/x86_64/unit_test.d --serialize-diagnostics /Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/Objects-normal/x86_64/unit_test.dia -c /Users/Niklas/Work/themachinery/foundation/unit_test.c -o /Users/Niklas/Work/themachinery/build/foundation/obj/MacOSX/Debug/foundation.build/Objects-normal/x86_64/unit_test.o
/Users/Niklas/Work/themachinery/foundation/unit_test.c:5:52: error: unused parameter 'inst' [-Werror,-Wunused-parameter] static bool should_run_file(tm_unit_test_runner_o *inst, const char *name)
Forgot to say -- this is with the 5.0.0-alpha13 release of premake.
Could you provide a complete simple reproduction?
I'm not familiar with the XCode module and it looks to not handle the disablewarnings API (might have missed it though).
@tdesveauxPKFX is correct, it's currently not supported. The last warning listed above microsoft-anon-tag isn't listed in the output. We should probably add the three warning APIs to Xcode; disablewarnings, enablewarnings, and fatalwarnings.
I believe I've tried to use this before and found that the only way to properly disable warnings was to use xcodebuildsettings. Using buildoptions will put them on the command line, but they're overridden due to ordering problems.
I tried using xcodebuildsettings as you suggested:
xcodebuildsettings {
"-Wno-missing-field-initializers",
"-Wno-unknown-pragmas",
"-Wno-unused-parameter",
"-Wno-unused-local-typedef",
"-Wno-missing-braces",
"-Wno-microsoft-anon-tag",
}
This gives me an error when running premake:
$ ./lib/premake-5.0.0-alpha13-macosx/premake5 xcode4
Building configurations...
Running action 'xcode4'...
Error: attempt to compare number with string
Without the xcodebuildsettings block I don't get this error.
from the code it looks to me like xcodebuildsettings wants a hashtable with string keys instead of an array, at least it's merged into a hashtable. that error might rise from the sort call on the keys where your input has numerical keys while the keys from inside premake are strings.
@WorldofBay is correct, xcodebuildsettings does take a hashtable, and the documentation on the wiki did not specify this detail. I have updated its page to hopefully clarify its usage.
Thanks, this work for me as a workaround.
I've added information about this to the disablewarnings page in case anyone else runs into it.
fatalwarnings has similar issue.