Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Remove use of designated initializers #26

Closed
springmeyer opened this issue Feb 3, 2014 · 3 comments
Closed

Remove use of designated initializers #26

springmeyer opened this issue Feb 3, 2014 · 3 comments

Comments

@springmeyer
Copy link
Contributor

Designated initializers are a c99 feature not officially unsupported in C++/C++11. They are used in the hershey font hack and this code will not compile with g++ on linux. Clang happens to support them but we should not depend on this. You can see that support is a clang c99 extension if you build with -pedantic:

$ clang++ -o t src/geometry/debug_font_buffer.cpp -pedantic -Iinclude
In file included from src/geometry/debug_font_buffer.cpp:5:
src/geometry/debug_font.cpp:3:22: warning: zero size arrays are an extension [-Wzero-length-array]
int8_t simplex_0[] = { };
                     ^
src/geometry/debug_font.cpp:108:16: warning: designated initializers are a C99 feature [-Wc99-extensions]
    [' ']  = { .width = 16, .length = sizeof(simplex_0), .data = simplex_0 },
               ^~~~~~~~~~~
src/geometry/debug_font.cpp:108:29: warning: designated initializers are a C99 feature [-Wc99-extensions]
    [' ']  = { .width = 16, .length = sizeof(simplex_0), .data = simplex_0 },
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
src/geometry/debug_font.cpp:108:58: warning: designated initializers are a C99 feature [-Wc99-extensions]
    [' ']  = { .width = 16, .length = sizeof(simplex_0), .data = simplex_0 },
                                                         ^~~~~~~~~~~~~~~~~
@kkaefer
Copy link
Member

kkaefer commented Feb 3, 2014

Dang, I knew that it was C99 only, but I thought I could sneak this through ;)

@springmeyer
Copy link
Contributor Author

It looks like this will compile with g++ 4.8:

glyph simplex[127] = {
   { 16, sizeof(simplex_0), simplex_0 },
   ....
};

Not sure if that breaks anything....

@kkaefer
Copy link
Member

kkaefer commented Feb 3, 2014

Should be fine, just less explicit.

@springmeyer springmeyer mentioned this issue Feb 3, 2014
@kkaefer kkaefer closed this as completed in 82c79b7 Feb 3, 2014
This was referenced Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants