floooh/sokol-samples

clear-sapp: non-trivial designated initializers not supported when used g++ MinGW compiler

Oldes opened this issue · 1 comments

Oldes commented

It looks that code like:

sg_setup(&(sg_desc){
.gl_force_gles2 = true,
.mtl_device = sapp_metal_get_device(),
.mtl_renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor,
.mtl_drawable_cb = sapp_metal_get_drawable,
.d3d11_device = sapp_d3d11_get_device(),
.d3d11_device_context = sapp_d3d11_get_device_context(),
.d3d11_render_target_view_cb = sapp_d3d11_get_render_target_view,
.d3d11_depth_stencil_view_cb = sapp_d3d11_get_depth_stencil_view
});

is not supported with MinGW g++ compiler:

g++.exe (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 7.2.0
sokol-samples\sapp\clear-sapp.c: In function 'void init()':
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
     });
     ^
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:20:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:21:34: error: expected primary-expression before ')' token
     pass_action = (sg_pass_action) {
                                  ^
sokol-samples\sapp\clear-sapp.c: In function 'sapp_desc sokol_main(int, char**)':
sokol-samples\sapp\clear-sapp.c:51:5: sorry, unimplemented: non-trivial designated initializers not supported
     };
     ^
sokol-samples\sapp\clear-sapp.c:51:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:51:5: sorry, unimplemented: non-trivial designated initializers not supported
sokol-samples\sapp\clear-sapp.c:51:5: sorry, unimplemented: non-trivial designated initializers not supported

My guess is that the clear-sapp.c source file is compiled as C++, not as C (maybe g++ defaults to C++ also for files with the .c file extension). Before C++20, C++ doesn't support C99-style designated init, and C++20 only supports a subset. Compiling the file as C should fix that, also on gcc (it definitely works on Linux, also with fairly old gcc versions).