diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index 177422fb7..3ee1f3b6e 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -1451,6 +1451,10 @@ static cc_result GetMachineID(cc_uint32* key) { return res; } #elif defined CC_BUILD_MACOS +/* kIOMasterPortDefault is deprecated since macOS 12.0 (replaced with kIOMainPortDefault) */ +/* And since kIOMasterPortDefault is just 0/NULL anyways, just manually declare it */ +static const mach_port_t masterPortDefault = 0; + /* Read kIOPlatformUUIDKey from I/O registry for the key */ static cc_result GetMachineID(cc_uint32* key) { io_registry_entry_t registry; @@ -1458,7 +1462,7 @@ static cc_result GetMachineID(cc_uint32* key) { char tmp[256] = { 0 }; #ifdef kIOPlatformUUIDKey - registry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/"); + registry = IORegistryEntryFromPath(masterPortDefault, "IOService:/"); if (!registry) return ERR_NOT_SUPPORTED; devID = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformUUIDKey), kCFAllocatorDefault, 0); @@ -1466,7 +1470,7 @@ static cc_result GetMachineID(cc_uint32* key) { DecodeMachineID(tmp, String_Length(tmp), key); } #else - registry = IOServiceGetMatchingService(kIOMasterPortDefault, + registry = IOServiceGetMatchingService(masterPortDefault, IOServiceMatching("IOPlatformExpertDevice")); devID = IORegistryEntryCreateCFProperty(registry, CFSTR(kIOPlatformSerialNumberKey), kCFAllocatorDefault, 0);