Skip to content

Instantly share code, notes, and snippets.

@michicc
Created January 22, 2026 19:28
Show Gist options
  • Select an option

  • Save michicc/3a4a62b9c3c171269e0e009e7998abb8 to your computer and use it in GitHub Desktop.

Select an option

Save michicc/3a4a62b9c3c171269e0e009e7998abb8 to your computer and use it in GitHub Desktop.
diff --git a/src/os/macosx/macos.mm b/src/os/macosx/macos.mm
index ee209917b6..99c17b2687 100644
--- a/src/os/macosx/macos.mm
+++ b/src/os/macosx/macos.mm
@@ -31,24 +31,13 @@ static NSAutoreleasePool *_ottd_autorelease_pool;
* @param return_major major version of the os. This would be 10 in the case of 10.4.11
* @param return_minor minor version of the os. This would be 4 in the case of 10.4.11
* @param return_bugfix bugfix version of the os. This would be 11 in the case of 10.4.11
- * A return value of -1 indicates that something went wrong and we don't know.
*/
void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix)
{
- *return_major = -1;
- *return_minor = -1;
- *return_bugfix = -1;
-
- if ([[ NSProcessInfo processInfo] respondsToSelector:@selector(operatingSystemVersion) ]) {
- IMP sel = [ [ NSProcessInfo processInfo] methodForSelector:@selector(operatingSystemVersion) ];
- NSOperatingSystemVersion ver = ((NSOperatingSystemVersion (*)(id, SEL))sel)([ NSProcessInfo processInfo], @selector(operatingSystemVersion));
-
- *return_major = (int)ver.majorVersion;
- *return_minor = (int)ver.minorVersion;
- *return_bugfix = (int)ver.patchVersion;
-
- return;
- }
+ NSOperatingSystemVersion = [ [ NSProcessInfo processInfo ] operatingSystemVersion ];
+ *return_major = (int)ver.majorVersion;
+ *return_minor = (int)ver.minorVersion;
+ *return_bugfix = (int)ver.patchVersion;
}
#ifdef WITH_COCOA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment