exception: added guards around builtin redefinition
clang fails to compile with this repository when the builtin's
for source locations are redefined. Detect their presence with
the appropriate builtin-check and avoid redefinition when
they are unnecessary.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie7905b10f0ca187586ffce95597979a719793348
diff --git a/src/stdplus/exception.cpp b/src/stdplus/exception.cpp
index 4635e84..c969295 100644
--- a/src/stdplus/exception.cpp
+++ b/src/stdplus/exception.cpp
@@ -1,6 +1,7 @@
#include <stdplus/exception.hpp>
// These will only be used if the compiler doesn't support them
+#if !__has_builtin(__builtin_LINE)
int __builtin_LINE()
{
return -1;
@@ -13,6 +14,7 @@
{
return "<unknown>";
}
+#endif
namespace stdplus
{
diff --git a/src/stdplus/exception.hpp b/src/stdplus/exception.hpp
index 22d9572..a7dbe8b 100644
--- a/src/stdplus/exception.hpp
+++ b/src/stdplus/exception.hpp
@@ -4,9 +4,11 @@
#include <utility>
// Forward declare builtins in case they are unsupported
+#if !__has_builtin(__builtin_LINE)
int __builtin_LINE();
const char* __builtin_FILE();
const char* __builtin_FUNCTION();
+#endif
namespace stdplus
{