29

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?

Jens
  • 65,924
  • 14
  • 115
  • 171
Alex Gaynor
  • 13,588
  • 9
  • 60
  • 110

5 Answers5

32

Turns out the correct answer is -Wno-error=unused-command-line-argument.

Alex Gaynor
  • 13,588
  • 9
  • 60
  • 110
12

You can also use this command:

-Wno-unused-command-line-argument
Enye Aaron Shi
  • 303
  • 4
  • 7
1

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.

naveenKumar
  • 327
  • 2
  • 9
0
#pragma clang diagnostic ignored "-Wunused-parameter"
BLUEPIXY
  • 39,049
  • 7
  • 31
  • 69
0

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.

user1725145
  • 3,927
  • 2
  • 36
  • 55