When using -Werror
with clang, it transforms "warning: argument unused during compilation" messages into errors, which makes sense. There's a -Qunused-arguments
flag to silence them entirely. My question is, is there some -Wno-error=...
flag I can pass to make these not be errors, without disabling them entirely?

- 69,818
- 15
- 125
- 179

- 14,353
- 9
- 63
- 113
-
4`unused-arguments` is about unused command line flags, not arguments in code. – Alex Gaynor Feb 07 '14 at 00:44
-
Which argument precisely is unused on the command line? – Jens Feb 07 '14 at 11:06
-
1Please show the whole command line and the whole message produced by clang. – Jens Feb 07 '14 at 13:43
-
Is the code your own? If so, then I would advice you to prevent the warning in the source code itself. See: http://stackoverflow.com/questions/3599160/unused-parameter-warnings-in-c-code – Ruud Helderman Feb 07 '14 at 15:03
6 Answers
Turns out the correct answer is -Wno-error=unused-command-line-argument
.

- 14,353
- 9
- 63
- 113
-
This seems necessary when runnning Clang with `-stdlib=libc++` through `distcc`. – rubenvb Jan 01 '17 at 22:04
-
Seems to have changed clang9 now uses -Qunused-arguments. – wheredidthatnamecomefrom Nov 22 '19 at 21:42
In my case, I had similar issues with autoconf while using clang-8 compiler in ./configure.
*clang-8: error: unknown argument: '-ftree-loop-distribute-patterns'*
*clang-8: error: unknown argument: '-fno-semantic-interposition'*
I needed following command line to fix these errors:
./configure CC=clang-8 CXX=clang++-8 LD=clang++-8 CFLAGS=-Qunused-arguments
Hope this is helpful to others.

- 367
- 4
- 10
-
Thanks for showing an example. This, however, does not work for `clang++` (I know the question tagged `c`. Just wanted to make it clear for anyone trying it for C++). https://godbolt.org/z/GqodhYWv7 – User 10482 May 27 '23 at 17:32
In Visual Studio 2019, open the property pages of the C++ Project and go to Configuration Properties -> C/C++ -> CommandLine.
In the "Additional Options" text box, paste
-Wunused-command-line-argument
Do this for each configuration / platform combination. This worked for me, to turn off only this warning.

- 3,993
- 2
- 37
- 58
Use --start-no-unused-arguments
and --end-no-unused-arguments
to silence the warning only for some arguments.
This is convenient for flags like -stdlib
(warns if used with C code), -rtlib
and -unwindlib
(warn if used during compilation as opposed to linking).

- 78,603
- 9
- 131
- 207