[c++] idl.h ERROR enum conflicts with windows define
https://github.com/google/flatbuffers/commit/f8380178600ff8255cc47694bddb321b2a9f648b https://github.com/wine-mirror/wine/blob/f2eebf36266fa0c3809472701763a6e468cd5ba3/include/wingdi.h#L1598
The result is a compile error if you reference both 1>/sdk/flatbuffers/24.3.25/include\flatbuffers/idl.h(636,49): error : expected identifier 1>C:\Program Files (x86)\Windows Kits\10\Include\10.0.26100.0\um\wingdi.h(118,29): message : expanded from macro 'ERROR'
Same for me on a MSYS2 windows machine. When windows.h is imported and idl.h there is a conflict. I had to do something like:
#define FLATBUFFER_VERSION_INT (FLATBUFFERS_VERSION_MAJOR * 10000 + FLATBUFFERS_VERSION_MINOR * 100 + FLATBUFFERS_VERSION_REVISION)
#if FLATBUFFER_VERSION_INT > 230121
#define FLATBUFFER_ERROR_8483
#endif
#ifdef FLATBUFFER_ERROR_8483
#define FLATBUFFER_ERROR_VAR_BACKUP ERROR
#undef ERROR
#endif
before idl.h is included.
Very ugly hack but it works. Note that it undefines ERROR from the windows include which might be a bad idea. I wonder why this issue wasn't reported much earlier because that change is from 2023.
This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.
not-stale
I have pushed a branch here, would one of you all be willing to test it?
Hey @jtdavis777 would you mind making a PR so I can see the diff?
I've opened the PR but realized I may have been a bit overzealous with my fix direction. Handling this in the preprocessor may be the better fix as what I've written may break other code bases.