q0987
q0987

Reputation: 35984

How to enable -Wunused-variable with -Wall?

I am using the following command to build C++14.

g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out

How to add the -Wunused-variable to the above line so that all warnings except -Wunused-variable are shown?

Upvotes: 1

Views: 958

Answers (1)

Barry
Barry

Reputation: 302718

From the gcc docs:

You can request many specific warnings with options beginning with ‘-W’, for example -Wimplicit to request warnings on implicit declarations. Each of these specific warning options also has a negative form beginning ‘-Wno-’ to turn off warnings; for example, -Wno-implicit.

So to disable the unused variable warning, you would pass -Wno-unused-variable

Upvotes: 2

Related Questions