Skip to content

Commit

Permalink
Merge pull request tlsa#167 from tlsa/tlsa/cpp-designated-initialisers
Browse files Browse the repository at this point in the history
Ensure C++ compatibility for designated initialisers
  • Loading branch information
tlsa committed Sep 17, 2021
2 parents 3d234d8 + 187117d commit b17eba9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ passing the `top_mapping_schema` that we defined above.
```c
/* Create our CYAML configuration. */
static const cyaml_config_t config = {
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
.log_fn = cyaml_log, /* Use the default logging function. */
.mem_fn = cyaml_mem, /* Use the default memory allocator. */
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
};

/* Where to store the loaded data */
Expand Down
2 changes: 1 addition & 1 deletion examples/numerical/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ static const cyaml_schema_value_t top_schema = {
* Here we have a very basic config.
*/
static const cyaml_config_t config = {
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
.log_fn = cyaml_log, /* Use the default logging function. */
.mem_fn = cyaml_mem, /* Use the default memory allocator. */
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
};

/* Main entry point from OS. */
Expand Down
2 changes: 1 addition & 1 deletion examples/planner/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,9 +410,9 @@ static const cyaml_schema_value_t plan_schema = {
* Here we have a very basic config.
*/
static const cyaml_config_t config = {
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
.log_fn = cyaml_log, /* Use the default logging function. */
.mem_fn = cyaml_mem, /* Use the default memory allocator. */
.log_level = CYAML_LOG_WARNING, /* Logging errors and warnings only. */
};

/* Main entry point from OS. */
Expand Down
16 changes: 8 additions & 8 deletions include/cyaml/cyaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,11 +579,11 @@ typedef enum cyaml_err {
_key, _flags, _structure, _member) \
{ \
.key = _key, \
.data_offset = offsetof(_structure, _member), \
.value = { \
CYAML_VALUE_INT(((_flags) & (~CYAML_FLAG_POINTER)), \
(((_structure *)NULL)->_member)), \
}, \
.data_offset = offsetof(_structure, _member) \
}

/**
Expand Down Expand Up @@ -1099,11 +1099,11 @@ typedef enum cyaml_err {
_key, _flags, _structure, _member, _fields) \
{ \
.key = _key, \
.data_offset = offsetof(_structure, _member), \
.value = { \
CYAML_VALUE_MAPPING(((_flags) | CYAML_FLAG_POINTER), \
(*(((_structure *)NULL)->_member)), _fields), \
}, \
.data_offset = offsetof(_structure, _member) \
}

/**
Expand Down Expand Up @@ -1163,14 +1163,14 @@ typedef enum cyaml_err {
_key, _flags, _structure, _member, _entry, _min, _max) \
{ \
.key = _key, \
.data_offset = offsetof(_structure, _member), \
.count_offset = offsetof(_structure, _member ## _count), \
.count_size = sizeof(((_structure *)NULL)->_member ## _count), \
.value = { \
CYAML_VALUE_SEQUENCE((_flags), \
(*(((_structure *)NULL)->_member)), \
_entry, _min, _max), \
}, \
.data_offset = offsetof(_structure, _member), \
.count_size = sizeof(((_structure *)NULL)->_member ## _count), \
.count_offset = offsetof(_structure, _member ## _count), \
}

/**
Expand Down Expand Up @@ -1211,14 +1211,14 @@ typedef enum cyaml_err {
_key, _flags, _structure, _member, _count, _entry, _min, _max) \
{ \
.key = _key, \
.data_offset = offsetof(_structure, _member), \
.count_offset = offsetof(_structure, _count), \
.count_size = sizeof(((_structure *)NULL)->_count), \
.value = { \
CYAML_VALUE_SEQUENCE((_flags), \
(*(((_structure *)NULL)->_member)), \
_entry, _min, _max), \
}, \
.data_offset = offsetof(_structure, _member), \
.count_size = sizeof(((_structure *)NULL)->_count), \
.count_offset = offsetof(_structure, _count), \
}

/**
Expand Down

0 comments on commit b17eba9

Please sign in to comment.