diff --git a/ion/Makefile b/ion/Makefile index 6ad8d9eb8..6e1b2fea2 100644 --- a/ion/Makefile +++ b/ion/Makefile @@ -9,7 +9,12 @@ SFLAGS += -Iion/include -DKD_CONFIG_H=1 include ion/src/$(PLATFORM)/Makefile include ion/src/shared/tools/Makefile -ion/src/shared/software_version.o: SFLAGS += -DPATCH_LEVEL=$(PATCH_LEVEL) -DVERSION=$(VERSION) +# We need to work around a GCC bug (concerning versions < 5.1). It is valid in +# C++11 to initialize a character array by providing a string litteral (e.g. +# char test[4]= "ab"; is valid and should initialize test to 'a','b',0,0). +# Older versions of GCC are not conformant so we resort to an initializer list. +initializer_list = $(shell echo $(1) | sed "s/\(.\)/'\1',/g")0 +ion/src/shared/software_version.o: SFLAGS += -DPATCH_LEVEL="$(call initializer_list,$(PATCH_LEVEL))" -DVERSION="$(call initializer_list,$(VERSION))" objs += $(addprefix ion/src/shared/, \ events.o \ diff --git a/ion/src/shared/software_version.cpp b/ion/src/shared/software_version.cpp index 9ec9030e9..60a6f693d 100644 --- a/ion/src/shared/software_version.cpp +++ b/ion/src/shared/software_version.cpp @@ -8,6 +8,10 @@ #error This file expects PATCH_LEVEL to be defined #endif +#ifndef VERSION +#error This file expects VERSION to be defined +#endif + #ifndef HEADER_SECTION #define HEADER_SECTION #endif @@ -16,8 +20,8 @@ class VersionInfo { public: constexpr VersionInfo() : m_header(Magic), - m_version(STR(VERSION)), - m_patchLevel(STR(PATCH_LEVEL)), + m_version{VERSION}, + m_patchLevel{PATCH_LEVEL}, m_footer(Magic) { } const char * version() const { assert(m_header == Magic);