Skip to content
Commit 9960bd95 authored by Mark Ruvald Pedersen's avatar Mark Ruvald Pedersen Committed by Anas Nashif
Browse files

portability: Ensure no C99-illegal semicolons exists in structs



Macro _OBJECT_TRACING_NEXT_PTR expands to a member or to nothing.
Macro _OBJECT_TRACING_NEXT_PTR is used in a number of places, like:

        struct k_stack {
                .. omitted ..
                _OBJECT_TRACING_NEXT_PTR(k_stack);
                u8_t flags;
        };

When the macro expands to nothing, a lonesome semi would remain. This is
illegal in C99, but permitted in GCC with GNU extensions.

Rather than expand to empty, we now expand to a zero-length array.
This means we can retain the trailing semis across structs wherein the
macro is used.

Note that zero-length array (foo[0]) != flexible array member (foo[]):
 * zero-length array: Is GNU+Clang extension. Anywhere in struct.
 * flexible array member: Is C99. Only in end of struct.

Thus we have really only traded-off one portability issue for
another, more acceptable, one at least.

Signed-off-by: default avatarMark Ruvald Pedersen <mped@oticon.com>
parent f0e2e1bc
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment