How to suppress -Weffc++ errors? is a FAQ to suppress the -Weffc++ flag, for example, when using Qt.
Operating system(s) or programming environment(s)
- Lubuntu 12.10 (quantal)
- Qt Creator 2.5.2
- G++ 4.7.2
Libraries used:
- 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
#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; }