Browse Source

Merge pull request #88527 from akien-mga/gdextension-fix-Wtype-limits-warning

GDExtension: Fix `-Wtype-limits` warning in `compatibility_maximum` patch check
Rémi Verschelde 1 year ago
parent
commit
34edb5b49a
2 changed files with 5 additions and 6 deletions
  1. 5 1
      core/extension/gdextension.cpp
  2. 0 5
      core/version.h

+ 5 - 1
core/extension/gdextension.cpp

@@ -929,9 +929,13 @@ Error GDExtensionResourceLoader::load_gdextension_resource(const String &p_path,
 			compatible = VERSION_MAJOR < compatibility_maximum[0];
 			compatible = VERSION_MAJOR < compatibility_maximum[0];
 		} else if (VERSION_MINOR != compatibility_maximum[1]) {
 		} else if (VERSION_MINOR != compatibility_maximum[1]) {
 			compatible = VERSION_MINOR < compatibility_maximum[1];
 			compatible = VERSION_MINOR < compatibility_maximum[1];
-		} else {
+		}
+#if VERSION_PATCH
+		// #if check to avoid -Wtype-limits warning when 0.
+		else {
 			compatible = VERSION_PATCH <= compatibility_maximum[2];
 			compatible = VERSION_PATCH <= compatibility_maximum[2];
 		}
 		}
+#endif
 
 
 		if (!compatible) {
 		if (!compatible) {
 			ERR_PRINT(vformat("GDExtension only compatible with Godot version %s or earlier: %s", compat_string, p_path));
 			ERR_PRINT(vformat("GDExtension only compatible with Godot version %s or earlier: %s", compat_string, p_path));

+ 0 - 5
core/version.h

@@ -47,13 +47,8 @@
 // forward-compatible.
 // forward-compatible.
 // Example: "3.1"
 // Example: "3.1"
 #define VERSION_BRANCH _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR)
 #define VERSION_BRANCH _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR)
-#if VERSION_PATCH
 // Example: "3.1.4"
 // Example: "3.1.4"
 #define VERSION_NUMBER VERSION_BRANCH "." _MKSTR(VERSION_PATCH)
 #define VERSION_NUMBER VERSION_BRANCH "." _MKSTR(VERSION_PATCH)
-#else // patch is 0, we don't include it in the "pretty" version number.
-// Example: "3.1" instead of "3.1.0"
-#define VERSION_NUMBER VERSION_BRANCH
-#endif // VERSION_PATCH
 
 
 // Version number encoded as hexadecimal int with one byte for each number,
 // Version number encoded as hexadecimal int with one byte for each number,
 // for easy comparison from code.
 // for easy comparison from code.