Skip to content

Latest commit

 

History

History
121 lines (67 loc) · 3.25 KB

CppSuppressEffCppErrors.md

File metadata and controls

121 lines (67 loc) · 3.25 KB

 

 

 

 

 

 

How to suppress -Weffc++ errors? is a FAQ to suppress the -Weffc++ flag, for example, when using Qt.

 

 

 

 

 

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

  • STL STL: GNU ISO C++ Library, version 4.7.2

 

 

 

 

 

Qt project file: CppSuppressEffCppErrors.pro

 


TEMPLATE = app CONFIG += console CONFIG -= qt QMAKE_CXXFLAGS += -std=c++11 -Werror -Wextra -Weffc++ SOURCES += main.cpp

 

 

 

 

 

main.cpp

 


#include <vector> #pragma GCC diagnostic ignored "-Weffc++" ///Suppress: ///error: 'MyClass::m_v' should be initialized in the member initialization list [-Werror=effc++] struct MyClass {   MyClass() {}   std::vector<int> m_v; }; #pragma GCC diagnostic pop ///Unsupress ///error: 'MyClass2::m_v' should be initialized in the member initialization list [-Werror=effc++] struct MyClass2 {   MyClass2() {} //Will not compile   std::vector<int> m_v; }; int main() {   MyClass v; }