# Plugin 64 vs 32 bit at runtime

**URL:** https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782
**Category:** General JUCE discussion
**Created:** [May 20, 2016, 8:14pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782 "2016-05-20T20:14:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)
#### Post date: [May 20, 2016, 8:14pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/1 "2016-05-20T20:14:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)
#### Post date: [May 20, 2016, 9:13pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/2 "2016-05-20T21:13:59Z")

</div>

For Mac and Windows I’m thinking…

```auto
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

---

<div class="post-metadata">

### Author: ![frankfilipanits](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/frankfilipanits/32/545_2.png) [@frankfilipanits](https://forum.juce.com/u/frankfilipanits)
#### Post date: [May 20, 2016, 9:14pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/3 "2016-05-20T21:14:47Z")

</div>

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.

```auto
    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
```

---

<div class="post-metadata">

### Author: ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)
#### Post date: [May 20, 2016, 9:15pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/4 "2016-05-20T21:15:42Z")

</div>

Thanks Frank!

Rail

---

<div class="post-metadata">

### Author: ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)
#### Post date: [May 20, 2016, 9:16pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/5 "2016-05-20T21:16:27Z")

</div>

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);
```

---

<div class="post-metadata">

### Author: ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)
#### Post date: [May 20, 2016, 9:22pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/6 "2016-05-20T21:22:10Z")

</div>

Thanks Anthony,

I think I’ll go with:

```auto
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

---

<div class="post-metadata">

### Author: ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)
#### Post date: [May 20, 2016, 9:24pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/7 "2016-05-20T21:24:58Z")

</div>

Looks good although I would vote for…

```
bool isSixtyFourBit()
{
    #if JUCE_64BIT
        return true;
    #else
        return false;
    #endif
}
```

---

<div class="post-metadata">

### Author: ![railjonrogut](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/railjonrogut/32/505_2.png) [@railjonrogut](https://forum.juce.com/u/railjonrogut)
#### Post date: [May 20, 2016, 9:46pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/8 "2016-05-20T21:46:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anthony-nicholls](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/anthony-nicholls/32/1246_2.png) [@anthony-nicholls](https://forum.juce.com/u/anthony-nicholls)
#### Post date: [May 20, 2016, 10:09pm UTC](https://forum.juce.com/t/plugin-64-vs-32-bit-at-runtime/17782/9 "2016-05-20T22:09:23Z")

</div>

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.
