Skip to content

[Discussion] C++ compilers really hate flexible array member. #139

Description

@apricot-azumi

C++ compilers really hate struct {...; char vla[];};. It gives warning for many struct declarations, which can be fortunately suppressed with:

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#include <usb.h>
#pragma GCC diagnostic pop

But USB_ARRAY_DESC and USB_STRING_DESC_CXX fails with no rescue.

One workaround is to use this in another C file, and use extern "C" in c++. LTO gives warning about type mismatch between units.

I personally use this https://godbolt.org/z/aTG1aEP96 in my project. This looks somewhat overkill and it requires C++17/20.

What's your opinion on compatibility with C++?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions