2013-07-08 10:46, Reece Dunn skrev:
Some info copied from the description of gcc 4.7.0: -Wmissing-field-initializers This warning is included in ‘-Wextra’. To get other ‘-Wextra’ warnings without this one, use ‘-Wextra -Wno-missing-field-initializers’. GCC normally defines __STDC__ to be 1, and in addition defines __STRICT_ANSI__ if you specify the ‘-ansi’ option, or a ‘-std’ option for strict conformance to some version of ISO C. ----------------- GLIBMM_INITIALIZE_STRUCT chooses the second alternative when __STRICT_ANSI__ is defined. More tests with gcc: $ gcc-4.7 -E -dM empty.cpp | grep STRICT $ gcc-4.7 -std=c++11 -E -dM empty.cpp | grep STRICT #define __STRICT_ANSI__ 1 $ gcc-4.7 -pedantic -Wextra -E -dM empty.cpp | grep STRICT $ gcc-4.7 -pedantic -Wextra -std=c++11 -E -dM empty.cpp | grep STRICT #define __STRICT_ANSI__ 1 $ gcc-4.7 -pedantic -Wextra -std=gnu++11 -E -dM empty.cpp | grep STRICT When no -std option is given, __STRICT_ANSI__ is not defined, and GLIBMM_INITIALIZE_STRUCT chooses the first alternative. The default value is -std=gnu++98. Solution? Why not use std::memset() in GLIBMM_INITIALIZE_STRUCT? Probable answer: Because it requires #include <cstring>. The glib macros G_GNUC_BEGIN_IGNORE_DEPRECATIONS and G_GNUC_END_IGNORE_DEPRECATIONS contain a trick that temporarily suppresses a particular warning. #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ _Pragma ("GCC diagnostic push") \ _Pragma ("GCC diagnostic ignored \"-Wdeprecated-declarations\"") #define G_GNUC_END_IGNORE_DEPRECATIONS \ _Pragma ("GCC diagnostic pop") #else #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS #define G_GNUC_END_IGNORE_DEPRECATIONS #endif I don't know exactly what kind of preprocessor directive _Pragma is. It might be useful in GLIBMM_INITIALIZE_STRUCT. Do we really need GLIBMM_INITIALIZE_STRUCT? There are 3 uses in glibmm and 6 in gtkmm. They can easily be replaced by std::memset(). Kjell |