How to silence unused command line argument error with clang without disabling it?

后端 未结 5 495
我寻月下人不归
我寻月下人不归 2021-02-01 04:22

When using -Werror with clang, it transforms \"warning: argument unused during compilation\" messages into errors, which makes sense. There\'s a -Qunused-argu

相关标签:
5条回答
  • 2021-02-01 04:40
    #pragma clang diagnostic ignored "-Wunused-parameter"
    
    0 讨论(0)
  • 2021-02-01 04:43

    You can also use this command:

    -Wno-unused-command-line-argument
    
    0 讨论(0)
  • 2021-02-01 04:54

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

    0 讨论(0)
  • 2021-02-01 04:55

    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.

    0 讨论(0)
  • 2021-02-01 05:02

    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.

    0 讨论(0)
提交回复
热议问题