Skip to content

Commit

Permalink
include: zephyr: net: coap_service: Use _CONCAT expansion
Browse files Browse the repository at this point in the history
Passing MACRO arguments that need expansion require _CONCAT.

Signed-off-by: Pieter De Gendt <[email protected]>
  • Loading branch information
pdgendt authored and MaureenHelm committed Oct 2, 2024
1 parent 96c6c78 commit 476c12f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions include/zephyr/net/coap_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct coap_service {
};

#define __z_coap_service_define(_name, _host, _port, _flags, _res_begin, _res_end) \
static struct coap_service_data coap_service_data_##_name = { \
static struct coap_service_data _CONCAT(coap_service_data_, _name) = { \
.sock_fd = -1, \
}; \
const STRUCT_SECTION_ITERABLE(coap_service, _name) = { \
Expand All @@ -69,7 +69,7 @@ struct coap_service {
.flags = _flags, \
.res_begin = (_res_begin), \
.res_end = (_res_end), \
.data = &coap_service_data_##_name, \
.data = &_CONCAT(coap_service_data_, _name), \
}

/** @endcond */
Expand Down Expand Up @@ -111,8 +111,8 @@ struct coap_service {
* @param _service Name of the associated service.
*/
#define COAP_RESOURCE_DEFINE(_name, _service, ...) \
STRUCT_SECTION_ITERABLE_ALTERNATE(coap_resource_##_service, coap_resource, _name) \
= __VA_ARGS__
STRUCT_SECTION_ITERABLE_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, \
_name) = __VA_ARGS__

/**
* @brief Define a CoAP service with static resources.
Expand All @@ -132,11 +132,11 @@ struct coap_service {
* @param _flags Configuration flags @see @ref COAP_SERVICE_FLAGS.
*/
#define COAP_SERVICE_DEFINE(_name, _host, _port, _flags) \
extern struct coap_resource _CONCAT(_coap_resource_##_name, _list_start)[]; \
extern struct coap_resource _CONCAT(_coap_resource_##_name, _list_end)[]; \
extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[]; \
extern struct coap_resource _CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[]; \
__z_coap_service_define(_name, _host, _port, _flags, \
&_CONCAT(_coap_resource_##_name, _list_start)[0], \
&_CONCAT(_coap_resource_##_name, _list_end)[0])
&_CONCAT(_CONCAT(_coap_resource_, _name), _list_start)[0], \
&_CONCAT(_CONCAT(_coap_resource_, _name), _list_end)[0])

/**
* @brief Count the number of CoAP services.
Expand Down Expand Up @@ -177,7 +177,7 @@ struct coap_service {
* @param _it Name of iterator (of type @ref coap_resource)
*/
#define COAP_RESOURCE_FOREACH(_service, _it) \
STRUCT_SECTION_FOREACH_ALTERNATE(coap_resource_##_service, coap_resource, _it)
STRUCT_SECTION_FOREACH_ALTERNATE(_CONCAT(coap_resource_, _service), coap_resource, _it)

/**
* @brief Iterate over all static resources associated with @p _service .
Expand Down

0 comments on commit 476c12f

Please sign in to comment.