When switching from mingw to visual studio, I added these lines to my global configuration header. (include it in stdafx.h)
#ifdef __GNUC__ //from https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html //Instead of put such pragma in code: //#pragma GCC diagnostic ignored "-Wformat" //use: //PRAGMA_GCC(diagnostic ignored "-Wformat") #define DO_PRAGMA(x) _Pragma (#x) #define PRAGMA_GCC(x) DO_PRAGMA(GCC #x) #define PRAGMA_MESSAGE(x) DO_PRAGMA(message #x) #define PRAGMA_WARNING(x) DO_PRAGMA(warning #x) #endif //__GNUC__ #ifdef _MSC_VER /* #define PRAGMA_OPTIMIZE_OFF __pragma(optimize("", off)) // These two lines are equivalent #pragma optimize("", off) PRAGMA_OPTIMIZE_OFF */ #define PRAGMA_GCC(x) // https://support2.microsoft.com/kb/155196?wa=wsignin1.0 #define __STR2__(x) #x #define __STR1__(x) __STR2__(x) #define __PRAGMA_LOC__ __FILE__ "("__STR1__(__LINE__)") " #define PRAGMA_WARNING(x) __pragma(message(__PRAGMA_LOC__ ": warning: " #x)) #define PRAGMA_MESSAGE(x) __pragma(message(__PRAGMA_LOC__ ": message : " #x)) #endif //#pragma message "message quoted" //#pragma message message unquoted //#warning warning unquoted //#warning "warning quoted" PRAGMA_MESSAGE(PRAGMA_MESSAGE unquoted) PRAGMA_MESSAGE("PRAGMA_MESSAGE quoted") #warning "#pragma warning quoted" PRAGMA_WARNING(PRAGMA_WARNING unquoted) PRAGMA_WARNING("PRAGMA_WARNING quoted")
Now I am using PRAGMA_WARNING (this needs to be fixed)
Unfortunately, gcc does not have #pragma warning , so it warns an unspecified pragma.
I doubt that gcc will add #pragma warning" instead of adding Microsoft #warning .
fantastory Oct 20 '16 at 7:24 2016-10-20 07:24
source share