Skip to content

Some examples can break due to dependency on headers coming from different files #850

@sleeptightAnsiC

Description

@sleeptightAnsiC

Many demo examples make an assumption that they can use symbols coming from a different file, due to indirect header inclusion.

For example, Nuklear/demo/common/overview.c uses libm math symbols, but never includes <math.h> or any similar header:

#include <limits.h> /* INT_MAX */
#include <time.h> /* struct tm, localtime */

for (id = 0, i = 0; i < 32; ++i) {
nk_chart_push_slot(ctx, (float)fabs(sin(id)), 0);
nk_chart_push_slot(ctx, (float)cos(id), 1);
nk_chart_push_slot(ctx, (float)sin(id), 2);
id += step;
}

This breaks, if I try to provide my own NK_SIN/NK_COS/STBTT_sqrt/etc in one of the demo files, and then remove the math header there.

This has happened to me when working on updated sdl3_renderer. In newer version of SDL3, <SDL3/SDL.h> does not pull <math.h> any more, and provides its own version of math symbols.

Note that Nuklear/demo/common/overview.c and <math.h> is just an example here. More demos are affected by this issue due to all kinds of headers.

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