summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libadhocutil/plugins.h3
-rw-r--r--libadhocutil/unique.h9
2 files changed, 11 insertions, 1 deletions
diff --git a/libadhocutil/plugins.h b/libadhocutil/plugins.h
index 69dd05c..5efd5b5 100644
--- a/libadhocutil/plugins.h
+++ b/libadhocutil/plugins.h
@@ -11,6 +11,7 @@
#include <set>
#include <algorithm>
#include "visibility.h"
+#include "unique.h"
namespace std {
DLL_PUBLIC
@@ -146,7 +147,7 @@ namespace AdHoc {
}
#define NAMEDPLUGIN(Name, Implementation, Base) \
- namespace { \
+ namespace MAKE_UNIQUE(__plugin__) { \
static void InstallPlugin() __attribute__((constructor(102))); \
void InstallPlugin() { \
::AdHoc::PluginManager::getDefault()->add<Base>(new Implementation(), Name, __FILE__, __LINE__); \
diff --git a/libadhocutil/unique.h b/libadhocutil/unique.h
new file mode 100644
index 0000000..5c77907
--- /dev/null
+++ b/libadhocutil/unique.h
@@ -0,0 +1,9 @@
+#ifndef ADHOCUTIL_UNIQUE_H
+#define ADHOCUTIL_UNIQUE_H
+
+#define CONCATENATE_DETAIL(x, y) x##y
+#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
+#define MAKE_UNIQUE(x) CONCATENATE(x, __COUNTER__)
+
+#endif
+