@@ -33,6 +33,7 @@ struct json_obj_descr {
33
33
const char * field_name ;
34
34
size_t field_name_len ;
35
35
size_t offset ;
36
+ size_t alignment ;
36
37
37
38
/* Valid values here: JSON_TOK_STRING, JSON_TOK_NUMBER,
38
39
* JSON_TOK_TRUE, JSON_TOK_FALSE, JSON_TOK_OBJECT_START,
@@ -95,6 +96,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
95
96
.field_name = (#field_name_), \
96
97
.field_name_len = sizeof(#field_name_) - 1, \
97
98
.offset = offsetof(struct_, field_name_), \
99
+ .alignment = __alignof__(struct_), \
98
100
.type = type_, \
99
101
}
100
102
@@ -128,6 +130,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
128
130
.field_name = (#field_name_), \
129
131
.field_name_len = (sizeof(#field_name_) - 1), \
130
132
.offset = offsetof(struct_, field_name_), \
133
+ .alignment = __alignof__(struct_), \
131
134
.type = JSON_TOK_OBJECT_START, \
132
135
.object = { \
133
136
.sub_descr = sub_descr_, \
@@ -166,11 +169,13 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
166
169
.field_name = (#field_name_), \
167
170
.field_name_len = sizeof(#field_name_) - 1, \
168
171
.offset = offsetof(struct_, field_name_), \
172
+ .alignment = __alignof__(struct_), \
169
173
.type = JSON_TOK_LIST_START, \
170
174
.array = { \
171
175
.element_descr = &(struct json_obj_descr) { \
172
176
.type = elem_type_, \
173
177
.offset = offsetof(struct_, len_field_), \
178
+ .alignment = __alignof__(struct_), \
174
179
}, \
175
180
.n_elements = (max_len_), \
176
181
}, \
@@ -221,6 +226,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
221
226
.field_name = (#field_name_), \
222
227
.field_name_len = sizeof(#field_name_) - 1, \
223
228
.offset = offsetof(struct_, field_name_), \
229
+ .alignment = __alignof__(struct_), \
224
230
.type = JSON_TOK_LIST_START, \
225
231
.array = { \
226
232
.element_descr = &(struct json_obj_descr) { \
@@ -230,6 +236,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
230
236
.sub_descr_len = elem_descr_len_, \
231
237
}, \
232
238
.offset = offsetof(struct_, len_field_), \
239
+ .alignment = __alignof__(struct_), \
233
240
}, \
234
241
.n_elements = (max_len_), \
235
242
}, \
@@ -258,6 +265,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
258
265
.field_name = (json_field_name_), \
259
266
.field_name_len = sizeof(json_field_name_) - 1, \
260
267
.offset = offsetof(struct_, struct_field_name_), \
268
+ .alignment = __alignof__(struct_), \
261
269
.type = type_, \
262
270
}
263
271
@@ -283,6 +291,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
283
291
.field_name = (json_field_name_), \
284
292
.field_name_len = (sizeof(json_field_name_) - 1), \
285
293
.offset = offsetof(struct_, struct_field_name_), \
294
+ .alignment = __alignof__(struct_), \
286
295
.type = JSON_TOK_OBJECT_START, \
287
296
.object = { \
288
297
.sub_descr = sub_descr_, \
@@ -318,11 +327,13 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
318
327
.field_name = (json_field_name_), \
319
328
.field_name_len = sizeof(json_field_name_) - 1, \
320
329
.offset = offsetof(struct_, struct_field_name_), \
330
+ .alignment = __alignof__(struct_), \
321
331
.type = JSON_TOK_LIST_START, \
322
332
.array = { \
323
333
.element_descr = &(struct json_obj_descr) { \
324
334
.type = elem_type_, \
325
335
.offset = offsetof(struct_, len_field_), \
336
+ .alignment = __alignof__(struct_), \
326
337
}, \
327
338
.n_elements = (max_len_), \
328
339
}, \
@@ -382,6 +393,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
382
393
.field_name = json_field_name_, \
383
394
.field_name_len = sizeof(json_field_name_) - 1, \
384
395
.offset = offsetof(struct_, struct_field_name_), \
396
+ .alignment = __alignof__(struct_), \
385
397
.type = JSON_TOK_LIST_START, \
386
398
.element_descr = &(struct json_obj_descr) { \
387
399
.type = JSON_TOK_OBJECT_START, \
@@ -390,6 +402,7 @@ typedef int (*json_append_bytes_t)(const char *bytes, size_t len,
390
402
.sub_descr_len = elem_descr_len_, \
391
403
}, \
392
404
.offset = offsetof(struct_, len_field_), \
405
+ .alignment = __alignof__(struct_), \
393
406
}, \
394
407
.n_elements = (max_len_), \
395
408
}
0 commit comments