DISTRHO Plugin Framework
Macros
Namespace Macros

Macros

#define DISTRHO_NAMESPACE   DISTRHO
 
#define START_NAMESPACE_DISTRHO   namespace DISTRHO_NAMESPACE {
 
#define END_NAMESPACE_DISTRHO   }
 
#define USE_NAMESPACE_DISTRHO   using namespace DISTRHO_NAMESPACE;
 

Detailed Description

C Macros to use and customize DPF namespaces.

These are macros that serve as helpers around C++ namespaces, and also as a way to set custom namespaces during a build.

Macro Definition Documentation

◆ DISTRHO_NAMESPACE

#define DISTRHO_NAMESPACE   DISTRHO

Compiler macro that sets the C++ namespace for DPF plugins.
If unset during build, it will use the name DISTRHO by default.

Unless you know exactly what you are doing, you do need to modify this value.
The only probable useful case for customizing it is if you are building a big collection of very similar DPF-based plugins in your application.
For example, having 2 different versions of the same plugin that should behave differently but still exist within the same binary.

On macOS (where due to Objective-C restrictions all code that interacts with Cocoa needs to be in a flat namespace), DPF will automatically use the plugin name as prefix to flat namespace functions in order to avoid conflicts.

So, basically, it is DPF's job to make sure plugin binaries are 100% usable as-is.
You typically do not need to care about this at all.

◆ START_NAMESPACE_DISTRHO

#define START_NAMESPACE_DISTRHO   namespace DISTRHO_NAMESPACE {

Compiler macro that begins the C++ namespace for DISTRHO, as needed for (the DSP side of) plugins.
All classes in DPF are within this namespace except for UI/graphics stuff.

See also
END_NAMESPACE_DISTRHO

◆ END_NAMESPACE_DISTRHO

#define END_NAMESPACE_DISTRHO   }

Close the namespace previously started by START_NAMESPACE_DISTRHO.
This doesn't really need to be a macro, it is just prettier/more consistent that way.

◆ USE_NAMESPACE_DISTRHO

#define USE_NAMESPACE_DISTRHO   using namespace DISTRHO_NAMESPACE;

Make the DISTRHO namespace available in the current function scope.
This is not set by default in order to avoid conflicts with commonly used names such as "Parameter" and "Plugin".