From a10c091114369dfdb8e734cd56a8cbc8dd7cdd06 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Thu, 17 Nov 2016 18:33:16 +1100 Subject: [PATCH] introspection: use pointers over arrays for type_name It's too hard to diagnose undefined symbol issues under clang so we use pointers for the time being. --- introspection.cpp | 28 ++++++++++++++-------------- introspection.hpp | 34 ++++++++++++++++++---------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/introspection.cpp b/introspection.cpp index fc14b51c..aad76c1a 100644 --- a/introspection.cpp +++ b/introspection.cpp @@ -18,21 +18,21 @@ /////////////////////////////////////////////////////////////////////////////// -constexpr char util::type_name::value[]; +constexpr const char* ::util::type_name::value; -constexpr char util::type_name< int8_t>::value[]; -constexpr char util::type_name< int16_t>::value[]; -constexpr char util::type_name< int32_t>::value[]; -constexpr char util::type_name< int64_t>::value[]; +constexpr const char* ::util::type_name< int8_t>::value; +constexpr const char* ::util::type_name< int16_t>::value; +constexpr const char* ::util::type_name< int32_t>::value; +constexpr const char* ::util::type_name< int64_t>::value; -constexpr char util::type_name< uint8_t>::value[]; -constexpr char util::type_name::value[]; -constexpr char util::type_name::value[]; -constexpr char util::type_name::value[]; +constexpr const char* ::util::type_name< uint8_t>::value; +constexpr const char* ::util::type_name::value; +constexpr const char* ::util::type_name::value; +constexpr const char* ::util::type_name::value; -constexpr char util::type_name::value[]; -constexpr char util::type_name::value[]; +constexpr const char* ::util::type_name::value; +constexpr const char* ::util::type_name::value; -constexpr char util::type_name::value[]; -constexpr char util::type_name::value[]; -constexpr char util::type_name::value[]; +constexpr const char* ::util::type_name::value; +constexpr const char* ::util::type_name::value; +constexpr const char* ::util::type_name::value; diff --git a/introspection.hpp b/introspection.hpp index e82cccfc..89eac97c 100644 --- a/introspection.hpp +++ b/introspection.hpp @@ -26,30 +26,32 @@ #include namespace util { + // XXX: we should be using a const char[] here, but clang-3.9 will not + // instantiate array values within template specialisations. template struct type_name; - template <> struct type_name { static constexpr const char value[] = "bool"; }; + template <> struct type_name { static constexpr const char *value = "bool"; }; - template <> struct type_name { static constexpr const char value[] = "char"; }; - template <> struct type_name { static constexpr const char value[] = "void*"; }; + template <> struct type_name { static constexpr const char *value = "char"; }; + template <> struct type_name { static constexpr const char *value = "void*"; }; - template <> struct type_name< int8_t> { static constexpr const char value[] = "int8"; }; - template <> struct type_name< int16_t> { static constexpr const char value[] = "int16"; }; - template <> struct type_name< int32_t> { static constexpr const char value[] = "int32"; }; - template <> struct type_name< int64_t> { static constexpr const char value[] = "int64"; }; + template <> struct type_name< int8_t> { static constexpr const char *value = "int8"; }; + template <> struct type_name< int16_t> { static constexpr const char *value = "int16"; }; + template <> struct type_name< int32_t> { static constexpr const char *value = "int32"; }; + template <> struct type_name< int64_t> { static constexpr const char *value = "int64"; }; - template <> struct type_name< uint8_t> { static constexpr const char value[] = "uint8"; }; - template <> struct type_name { static constexpr const char value[] = "uint16"; }; - template <> struct type_name { static constexpr const char value[] = "uint32"; }; - template <> struct type_name { static constexpr const char value[] = "uint64"; }; + template <> struct type_name< uint8_t> { static constexpr const char *value = "uint8"; }; + template <> struct type_name { static constexpr const char *value = "uint16"; }; + template <> struct type_name { static constexpr const char *value = "uint32"; }; + template <> struct type_name { static constexpr const char *value = "uint64"; }; - template <> struct type_name { static constexpr const char value[] = "float32"; }; - template <> struct type_name { static constexpr const char value[] = "float64"; }; + template <> struct type_name { static constexpr const char *value = "float32"; }; + template <> struct type_name { static constexpr const char *value = "float64"; }; - template <> struct type_name { static constexpr const char value[] = "string"; }; - template <> struct type_name { static constexpr const char value[] = "cstring"; }; - template <> struct type_name { static constexpr const char value[] = "cstring"; }; + template <> struct type_name { static constexpr const char *value = "string"; }; + template <> struct type_name { static constexpr const char *value = "cstring"; }; + template <> struct type_name { static constexpr const char *value = "cstring"; }; template constexpr