From b4e23600701d08c3f1f862f04f4bc82ad42c6686 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Sat, 3 Jun 2017 18:02:42 -0400 Subject: [PATCH] uORB generation use constexpr (#7348) --- msg/templates/uorb/msg.cpp.template | 2 +- msg/templates/uorb/msg.h.template | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/msg/templates/uorb/msg.cpp.template b/msg/templates/uorb/msg.cpp.template index d704f66207..86d151a5be 100644 --- a/msg/templates/uorb/msg.cpp.template +++ b/msg/templates/uorb/msg.cpp.template @@ -69,7 +69,7 @@ topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), fiel @# join all msg files in one line e.g: "float[3] position;float[3] velocity;bool armed" @# This is used for the logger -const char *__orb_@(topic_name)_fields = "@( ";".join(topic_fields) );"; +constexpr char __orb_@(topic_name)_fields[] = "@( ";".join(topic_fields) );"; @[for multi_topic in topics]@ ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), diff --git a/msg/templates/uorb/msg.h.template b/msg/templates/uorb/msg.h.template index b890bf88b5..ca22c4338e 100644 --- a/msg/templates/uorb/msg.h.template +++ b/msg/templates/uorb/msg.h.template @@ -129,7 +129,7 @@ for constant in spec.constants: else: raise Exception("Type {0} not supported, add to to template file!".format(type_name)) - print('\tstatic const %s %s = %s;'%(type_px4, constant.name, int(constant.val))) + print('\tstatic constexpr %s %s = %s;'%(type_px4, constant.name, int(constant.val))) } #endif };