You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately, there are a lot of flexible arrays in the USB by design. I don't have much experience with pluses, but I think it would be a good idea to place all descriptors and the descriptor handling callback into a separate C file, compile it using C to object, and let the linker do its job.
P.S. USB_ARRAY_DESC and USB_STRING_DESC are just helper macros. All descriptors are just byte arrays, usually located in the .rodata section. I don't see how the linker might try to optimize this.
C++ compilers really hate
struct {...; char vla[];};
. It gives warning for many struct declarations, which can be fortunately suppressed with:But
USB_ARRAY_DESC
andUSB_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++?
The text was updated successfully, but these errors were encountered: