lib: make g++ happy with plugin-dev.h macros
authorSimon Marchi <simon.marchi@efficios.com>
Sun, 18 Aug 2019 16:42:35 +0000 (12:42 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 20 Aug 2019 02:02:29 +0000 (22:02 -0400)
g++ doesn't like the syntax used for assigning structures in the plugin
macros:

  /tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:599:3: error: expected primary-expression before ‘.’ token
     .value._attr_name = _x,     \
     ^
  /tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:871:2: note: in expansion of macro ‘__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE’
    __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE(source_msg_iter_init_method, BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD, _id, _comp_class_id, source, _x)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /tmp/babeltrace/include/babeltrace2/plugin/plugin-dev.h:1356:2: note: in expansion of macro ‘BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID’
    BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD_WITH_ID(auto, _name, _x)
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  can.cpp:829:1: note: in expansion of macro ‘BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD’
   BT_PLUGIN_SOURCE_COMPONENT_CLASS_MESSAGE_ITERATOR_INIT_METHOD(CANSource, can_iter_init);
   ^

Changing

    .value._attr_name = _x

to

    .value = { ._attr_name = _x }

makes it work. There are a few instances of this, I changed all I found.

Built-tested with gcc 7.4.0 and clang-9, and verified that a plugin compiled
with g++ 7.4.0 works.

Change-Id: I17cb4edf1082003dc0bb9d0fae906c391daf3da4
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1964
Reviewed-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Tested-by: jenkins <jenkins@lttng.org>
include/babeltrace2/plugin/plugin-dev.h

index cf47d00ef6a07624a5cbe8aa89638176ec052f95..d1ea59887c57a19beeef2376663687aeab496cae 100644 (file)
@@ -452,7 +452,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
                .plugin_descriptor = &__bt_plugin_descriptor_##_id,     \
                .type_name = #_attr_name,                               \
                .type = _attr_type,                                     \
-               .value._attr_name = _x,                                 \
+               .value = { ._attr_name = _x },                          \
        };                                                              \
        static struct __bt_plugin_descriptor_attribute const * const __bt_plugin_descriptor_attribute_##_id##_##_attr_name##_ptr __BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_descriptor_attribute_##_id##_##_attr_name
 
@@ -530,13 +530,11 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
  */
 #define BT_PLUGIN_SOURCE_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _msg_iter_next_method) \
        static struct __bt_plugin_component_class_descriptor __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id = { \
-               .plugin_descriptor = &__bt_plugin_descriptor_##_id,     \
-               .name = _name,                                          \
-               .type = BT_COMPONENT_CLASS_TYPE_SOURCE,                 \
-               .methods.source = {                                     \
-                       .msg_iter_next = _msg_iter_next_method, \
-               },                                                      \
-       };                                                              \
+               .plugin_descriptor = &__bt_plugin_descriptor_##_id,                     \
+               .name = _name,                                                          \
+               .type = BT_COMPONENT_CLASS_TYPE_SOURCE,                                 \
+               .methods = { .source = { .msg_iter_next = _msg_iter_next_method } },    \
+       };                                                                              \
        static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_source_component_class_descriptor_##_id##_##_comp_class_id
 
 /*
@@ -550,13 +548,11 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
  */
 #define BT_PLUGIN_FILTER_COMPONENT_CLASS_WITH_ID(_id, _comp_class_id, _name, _msg_iter_next_method) \
        static struct __bt_plugin_component_class_descriptor __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id = { \
-               .plugin_descriptor = &__bt_plugin_descriptor_##_id,     \
-               .name = _name,                                          \
-               .type = BT_COMPONENT_CLASS_TYPE_FILTER,                 \
-               .methods.filter = {                                     \
-                       .msg_iter_next = _msg_iter_next_method, \
-               },                                                      \
-       };                                                              \
+               .plugin_descriptor = &__bt_plugin_descriptor_##_id,                     \
+               .name = _name,                                                          \
+               .type = BT_COMPONENT_CLASS_TYPE_FILTER,                                 \
+               .methods = { .filter = { .msg_iter_next = _msg_iter_next_method } },    \
+       };                                                                              \
        static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_filter_component_class_descriptor_##_id##_##_comp_class_id
 
 /*
@@ -573,9 +569,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
                .plugin_descriptor = &__bt_plugin_descriptor_##_id,     \
                .name = _name,                                          \
                .type = BT_COMPONENT_CLASS_TYPE_SINK,                   \
-               .methods.sink = {                                       \
-                       .consume = _consume_method,                     \
-               },                                                      \
+               .methods = { .sink = { .consume = _consume_method } },  \
        };                                                              \
        static struct __bt_plugin_component_class_descriptor const * const __bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRS = &__bt_plugin_sink_component_class_descriptor_##_id##_##_comp_class_id
 
@@ -596,7 +590,7 @@ struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_
                .comp_class_descriptor = &__bt_plugin_##_type##_component_class_descriptor_##_id##_##_comp_class_id, \
                .type_name = #_attr_name,                               \
                .type = _attr_type,                                     \
-               .value._attr_name = _x,                                 \
+               .value = { ._attr_name = _x },                          \
        };                                                              \
        static struct __bt_plugin_component_class_descriptor_attribute const * const __bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name##_ptr __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_ATTRS = &__bt_plugin_##_type##_component_class_descriptor_attribute_##_id##_##_comp_class_id##_##_attr_name
 
This page took 0.025779 seconds and 4 git commands to generate.