memononen / nanovg

Antialiased 2D vector drawing library on top of OpenGL for UI and visualizations.
zlib License
5.2k stars 779 forks source link

NVGcolor is not strictly C99 compliant #220

Open PyryM opened 9 years ago

PyryM commented 9 years ago
struct NVGcolor {
    union {
        float rgba[4];
        struct {
            float r,g,b,a;
        };
    };
};

The internal anonymous struct is inaccessible in strict C99 (see this stack overflow question: http://stackoverflow.com/questions/1972003/how-to-compile-c-code-with-anonymous-structs-unions) and this type breaks some automatic binding generators (for example terra's terralib.includec(...) generates a malformed type for this).

PyryM commented 9 years ago

Actually, the union inside the struct is also anonymous and that causes issues. Changing the definition to:

union NVGcolor {
    float rgba[4];
    struct {
        float r, g, b, a;
    };
};

would let strict c99 still access rgba via var.rgba[idx] even though the individual channels wouldn't be available.