rory
April 3, 2017, 5:09pm
1
I need a catchall OS detection for OSX, but checking SystemStats::getOperatingSystemType() for SystemStats::OperatingSystemType::MacOSX on my OSX machine doesn’t work so I have to do (look away now!)
if(SystemStats::getOperatingSystemType() == SystemStats::OperatingSystemType::MacOSX_10_8
|| SystemStats::getOperatingSystemType() == SystemStats::OperatingSystemType::MacOSX_10_9
|| SystemStats::getOperatingSystemType() == SystemStats::OperatingSystemType::MacOSX_10_10
|| SystemStats::getOperatingSystemType() == SystemStats::OperatingSystemType::MacOSX_10_11
|| SystemStats::getOperatingSystemType() == SystemStats::OperatingSystemType::MacOSX_10_12)
I have some utility functions I include in my main header which I can use throughout my app/plugin
bool isWindows()
{
#if JUCE_WINDOWS
return true;
#else
return false;
#endif
}
bool isSixtyFourBit()
{
#if JUCE_64BIT
return true;
#else
return false;
#endif
}
If you support more than Mac and Windows you can create a similar isMacOS() using JUCE_MAC
Rail
rory
April 3, 2017, 7:03pm
3
That’ll do alright. Thanks. I’m still curious to know if the MacOSX OperatingSystemType is broken or not.
It works fine here using SystemStats::getOperatingSystemName()
if (SystemStats::isOperatingSystem64Bit())
Logger::writeToLog (String ("Operating System:").paddedRight (' ', iPaddingLength) + SystemStats::getOperatingSystemName() + " - [64 Bit]");
else
Logger::writeToLog (String ("Operating System:").paddedRight (' ', iPaddingLength) + SystemStats::getOperatingSystemName());
Generates:
Operating System: Mac OSX 10.11.6 - [64 Bit]
Using:
SystemStats::OperatingSystemType type = SystemStats::getOperatingSystemType();
DBG ("Type: 0x" + String::toHexString (type).paddedLeft ('0', 4));
Generates:
Type: 0x010b
Which is correct. (MacOS 10.11.6)
To check against SystemStats::OperatingSystemType::MacOSX you have to check the correct bit.
if (SystemStats::getOperatingSystemType() & SystemStats::MacOSX)
DBG ("Running under MacOS");
I think my free functions are a better solution for testing which platform you’re running under though.
Rail
rory
April 3, 2017, 8:04pm
5
Ah thanks Rail. It makes sense now. I probably will adapt your functions for my own use. Cheers.
Cool, just for clarification… my function isSixtyFourBit() reports if the current app/plugin is 64 bit – not the OS.
Cheers,
Rail
rory
April 3, 2017, 9:22pm
7
But I guess I could do something like:
bool isMac()
{
#if JUCE_MACOSX
return true;
#else
return false;
#endif
}
JUCE_MACOSX isn’t defined anywhere by JUCE… it does define JUCE_MAC
bool isMacOS()
{
#if JUCE_MAC
return true;
#else
return false;
#endif
}
Rail
2 Likes
rory
April 3, 2017, 10:01pm
9
True. I’m writing without docs and from my phone!
fr810
April 4, 2017, 9:08am
11
I don’t see how your if statement can work but the if statement as shown in the docs doesn’t work:
if ((SystemStats::getOperatingSystemType() & SystemStats::MacOSX) != 0)
rory
April 4, 2017, 9:21am
12
I am assuming that’s a typo Fabian. Thank you, this does work. I’m going to hold my hand up now and admit to not having looked at the docs