diff --git a/src/indexer.cc b/src/indexer.cc index 5a6f953a..2beed72d 100644 --- a/src/indexer.cc +++ b/src/indexer.cc @@ -170,7 +170,7 @@ struct ConstructorCache { if (ctors.empty()) return nullopt; - Usr best_usr; + Usr best_usr = ctors[0].usr; int best_score = INT_MIN; // Scan constructors for the best possible match. diff --git a/src/port.h b/src/port.h new file mode 100644 index 00000000..7f451ab3 --- /dev/null +++ b/src/port.h @@ -0,0 +1,7 @@ +#pragma once + +#if defined(__GNUC__) && !defined(__clang__) +#define ATTRIBUTE_UNUSED __attribute__((unused)) +#else +#define ATTRIBUTE_UNUSED +#endif diff --git a/src/serializer.h b/src/serializer.h index 32ee67df..1132af14 100644 --- a/src/serializer.h +++ b/src/serializer.h @@ -1,5 +1,7 @@ #pragma once +#include "port.h" + #include #include #include @@ -73,12 +75,16 @@ struct IndexFile; #define REFLECT_MEMBER(name) ReflectMember(visitor, #name, value.name) #define REFLECT_MEMBER2(name, value) ReflectMember(visitor, name, value) -#define MAKE_REFLECT_TYPE_PROXY(type, as_type) \ - template \ - void Reflect(TVisitor& visitor, type& value) { \ - auto value0 = static_cast(value); \ - ::Reflect(visitor, value0); \ - value = static_cast(value0); \ +// TODO Make it inline because this macro can be used in header files. +#define MAKE_REFLECT_TYPE_PROXY(type, as_type) \ + ATTRIBUTE_UNUSED inline void Reflect(Reader& visitor, type& value) { \ + as_type value0; \ + ::Reflect(visitor, value0); \ + value = static_cast(value0); \ + } \ + inline void Reflect(Writer& visitor, type& value) { \ + auto value0 = static_cast(value); \ + ::Reflect(visitor, value0); \ } #define _MAPPABLE_REFLECT_MEMBER(name) REFLECT_MEMBER(name);