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

Remove use of designated initializers #26

Closed

Description

@springmeyer

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 },
                                                         ^~~~~~~~~~~~~~~~~

Activity

  1. kkaefer commented on Feb 3, 2014

    @kkaefer
    Member

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

  2. springmeyer commented on Feb 3, 2014

    @springmeyer
    ContributorAuthor

    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....

  3. kkaefer commented on Feb 3, 2014

    @kkaefer
    Member

    Should be fine, just less explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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