Osvaldo Alvarez
Osvaldo Alvarez

Reputation: 21

Disable override warning C++

I'm compiling my c++ project with the flag -std=c++11 because I use override in one of my classes, even so I'm getting this warning:

warning: override controls (override/final) only available with -
std=c++11 or -std=gnu++11 [enabled by default]

I would like to know how to disable this warning or I would appreciate if you can tell me what I am doing wrong.

Upvotes: 0

Views: 2384

Answers (2)

Sly_TheKing
Sly_TheKing

Reputation: 528

You can disable warning with pragma

#pragma warning( disable : _WARNING_NUMBER_)

Where _WARNING_NUMBER_ is number of your warning

However, you should always listen to your compiler and fix the warning instead of disabling

Upvotes: 0

eerorika
eerorika

Reputation: 238351

I don't think that warning can be separately disabled.

Instead of disabling the warning, I recommend that you fix the bug. Your code uses a language feature that was introduced in C++11, but you compile with an earlier standard enabled. You have two options:

  • Do not use new ("new"; it's been 6 years...) standard features that are not supported by the the standard (and the compiler) that you use.
  • Compile with new standard version enabled, using a compiler that supports that standard feature.

Upvotes: 1

Related Questions