summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cppbuild.cc8
-rw-r--r--libcppbuild.h6
2 files changed, 12 insertions, 2 deletions
diff --git a/cppbuild.cc b/cppbuild.cc
index 50c364f..d3d21be 100644
--- a/cppbuild.cc
+++ b/cppbuild.cc
@@ -147,6 +147,10 @@ BuildConfigurations myConfigs2()
};
}
-int a = reg(__FILE__, myConfigs);
-int b = reg(__FILE__, myConfigs2);
+//int a = reg(__FILE__, myConfigs);
+//int b = reg(__FILE__, myConfigs2);
}
+
+// Convenience macro
+REG(myConfigs);
+REG(myConfigs2);
diff --git a/libcppbuild.h b/libcppbuild.h
index 5b442f8..2aba987 100644
--- a/libcppbuild.h
+++ b/libcppbuild.h
@@ -27,3 +27,9 @@ struct BuildConfiguration
using BuildConfigurations = std::vector<BuildConfiguration>;
int reg(const char* location, BuildConfigurations (*cb)());
+
+// Convenience macro - ugly but keeps things simple(r)
+#define CONCAT(a, b) CONCAT_INNER(a, b)
+#define CONCAT_INNER(a, b) a ## b
+#define UNIQUE_NAME(base) CONCAT(base, __LINE__)
+#define REG(cb) namespace { int UNIQUE_NAME(unique) = reg(__FILE__, cb); }