Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expected constant expression #2

Open
tang1024 opened this issue Dec 4, 2019 · 1 comment
Open

Expected constant expression #2

tang1024 opened this issue Dec 4, 2019 · 1 comment

Comments

@tang1024
Copy link

tang1024 commented Dec 4, 2019

Found a bug when compiling the source.

Location
Line 96, flecs-systems-sdl2/src/render.c

Bug
uint8_t point_count = shape->point_count;
ecs_assert(point_count <= 8, ECS_INVALID_PARAMETER, NULL);
EcsPoint2D points[point_count]; // <<< dynamic c variable but static c array; however, point_count is not determined at compile time; use dynamic array instead

Easy Fix
EcsPoint2D* points = malloc(point_count * sizeof(points[0]));
free(points);

Similarly,
Sint16* gfx_x = malloc(point_count * sizeof(gfx_x[0]));
Sint16* gfx_y = malloc(point_count * sizeof(gfx_y[0]));
free(gfx_x);
free(gfx_y);

@SanderMertens
Copy link
Member

Hi @tang1024, thanks for reporting the issue!

This is a "variable sized array" which was added in C99, but unfortunately not supported by msvc. I'll update the code to use something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants