Anyone come up with a cross-platform way to detect at runtime if the plugin is 32 or 64 bit?
I need to spawn a new process – and I want to spawn the process which matches the current plugin bit size.
Cheers,
Rail
Anyone come up with a cross-platform way to detect at runtime if the plugin is 32 or 64 bit?
I need to spawn a new process – and I want to spawn the process which matches the current plugin bit size.
Cheers,
Rail
For Mac and Windows I’m thinking…
bool isWindows()
{
#if JUCE_WINDOWS
return true;
#else
return false;
#endif
}[/code]
[code]bool isSixtyFourBit()
{
if (isWindows())
{
#ifdef _WIN32
return false;
#endif
}
else
{
#ifdef __i386__
return false;
#endif
}
return true;
}
Anyone see any flaws?
Rail
This snippet from my PluginEditor code fills a string with the current version, format, and bit depth – seems to work well on Windows and OSX.
String displayString("Version ");
displayString += JucePlugin_VersionString;
displayString += " ";
switch (getProcessor()->wrapperType)
{
case AudioProcessor::wrapperType_VST:
displayString += "VST";
break;
case AudioProcessor::wrapperType_VST3:
displayString += "VST3";
break;
case AudioProcessor::wrapperType_AudioUnit:
displayString += "AU";
break;
case AudioProcessor::wrapperType_RTAS:
displayString += "RTAS";
break;
case AudioProcessor::wrapperType_AAX:
displayString += "AAX";
break;
default:
displayString += "Unknown";
break;
}
#if defined(__LP64__) || defined(_WIN64)
displayString += String(" (64)");
#else
displayString += String(" (32)");
#endif
#ifdef _DEBUG
displayString += String(" DEBUG");
#endif
Thanks Frank!
Rail
I would normally use a pre-processor definition, it seems however that JUCE_64BIT and JUCE_32BIT are not always defined so they can’t be used in runtime if statments unless you add something like this…
#ifndef JUCE_64BIT
#define JUCE_64BIT 0
#endif
Then you can do things like…
DBG (String (JUCE_64BIT ? "64 bit" : "32 bit"));
However to avoid the additional defines you can always do something like…
#if JUCE_64BIT
String architecture ("64 bit");
#else
String architecture ("32 bit");
#endif
DBG (architecture);
Thanks Anthony,
I think I’ll go with:
bool isWindows()
{
#if JUCE_WINDOWS
return true;
#else
return false;
#endif
}[/code]
[code]bool isSixtyFourBit()
{
if (isWindows())
{
#ifdef _WIN64
return true;
#endif
}
else
{
#ifdef __LP64__
return true;
#endif
}
return false;
}
Cheers,
Rail
Looks good although I would vote for…
bool isSixtyFourBit()
{
#if JUCE_64BIT
return true;
#else
return false;
#endif
}
That would work if we can rely on JUCE_64BIT being defined to 0 for a 32 bit build – the pre-amble to your previous post made me think that wasn’t always true…
I guess I can add the definition to zero in AppConfig.h and use your version
Rail
No for the pre-processor if statements if they are not defined they will result in a 0 or false outcome, it’s just when you want to use it in a runtime if statement.
If you look around the JUCE code you will see plenty of examples including this in juce_android_SystemStats.cpp…
bool SystemStats::isOperatingSystem64Bit()
{
#if JUCE_64BIT
return true;
#else
return false;
#endif
}
It’s actually no different for JUCE_WINDOWS in that it’s also never defined as 0. I would go as far as to say that JUCE pretty much only ever defines these kind of preprocessor definitions as 1.