Browse Source

Fix mingw compilation

Michael Ragazzon 5 years ago
parent
commit
d6144ede17
2 changed files with 15 additions and 13 deletions
  1. 3 1
      Include/RmlUi/Core/Platform.h
  2. 12 12
      Include/RmlUi/Core/TypeConverter.inl

+ 3 - 1
Include/RmlUi/Core/Platform.h

@@ -127,7 +127,9 @@
     break;
 
 // Tell the compiler of printf-like functions, warns on incorrect usage.
-#if defined __GNUC__ || defined __clang__
+#if defined __MINGW32__
+#  define RMLUI_ATTRIBUTE_FORMAT_PRINTF(i, f) __attribute__((format (__MINGW_PRINTF_FORMAT, i, f)))
+#elif defined __GNUC__ || defined __clang__
 #  define RMLUI_ATTRIBUTE_FORMAT_PRINTF(i, f) __attribute__((format (printf, i, f)))
 #else
 #  define RMLUI_ATTRIBUTE_FORMAT_PRINTF(i, f)

+ 12 - 12
Include/RmlUi/Core/TypeConverter.inl

@@ -35,6 +35,13 @@ bool TypeConverter<SourceType, DestType>::Convert(const SourceType& /*src*/, Des
 	return false;
 }
 
+#if defined(RMLUI_PLATFORM_WIN32) && defined(__MINGW32__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat"
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-extra-args"
+#endif
+
 ///
 /// Full Specialisations
 ///
@@ -167,13 +174,6 @@ public:
 	}
 };
 
-#if defined(RMLUI_PLATFORM_WIN32) && defined(__MINGW32__)
-	#pragma GCC diagnostic push
-	#pragma GCC diagnostic ignored "-Wformat"
-	#pragma GCC diagnostic push
-	#pragma GCC diagnostic ignored "-Wformat-extra-args"
-#endif
-
 template<>
 class TypeConverter< String, int64_t >
 {
@@ -194,11 +194,6 @@ public:
 	}
 };
 
-#if defined(RMLUI_PLATFORM_WIN32) && defined(__MINGW32__)
-	#pragma GCC diagnostic pop
-	#pragma GCC diagnostic pop
-#endif
-
 template<>
 class TypeConverter< String, bool >
 {
@@ -389,4 +384,9 @@ VECTOR_STRING_CONVERTER(Colourb, byte, 4);
 #undef STRING_VECTOR_CONVERTER
 #undef VECTOR_STRING_CONVERTER
 
+#if defined(RMLUI_PLATFORM_WIN32) && defined(__MINGW32__)
+#pragma GCC diagnostic pop
+#pragma GCC diagnostic pop
+#endif
+
 } // namespace Rml