Skip to content

duplicated sizeof checks in src/nuklear_internal.h #889

@sleeptightAnsiC

Description

@sleeptightAnsiC

Follow up from #884 (comment)

/* Make sure correct type size:
* This will fire with a negative subscript error if the type sizes
* are set incorrectly by the compiler, and compile out if not */
NK_STATIC_ASSERT(sizeof(nk_size) >= sizeof(void*));
NK_STATIC_ASSERT(sizeof(nk_ptr) == sizeof(void*));
NK_STATIC_ASSERT(sizeof(nk_flags) >= 4);
NK_STATIC_ASSERT(sizeof(nk_rune) >= 4);
NK_STATIC_ASSERT(sizeof(nk_ushort) == 2);
NK_STATIC_ASSERT(sizeof(nk_short) == 2);
NK_STATIC_ASSERT(sizeof(nk_uint) == 4);
NK_STATIC_ASSERT(sizeof(nk_int) == 4);
NK_STATIC_ASSERT(sizeof(nk_byte) == 1);
NK_STATIC_ASSERT(sizeof(nk_bool) <= sizeof(int));

I wonder why do we need these duplicated checks here? The ones from src/nuklear.h do the very same thing, and all src/*.c files are including both of those headers, so I'm not sure what is the benefit?

This thing can only really harm us, just like in case of #185 where the sizeof(nk_bool) checks were different between each file, and went unnoticed for so long.

In theory having some duplication in src/nuklear.h may make sense, but in practice those checks just do nothing. The proper sizes are already ensured at the moment when any of those is hit. This just looks like a dead code to me at this point.

I'm planning to remove this unless someone has a good reason to keep it (?)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions