-
Notifications
You must be signed in to change notification settings - Fork 578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with NK_STATIC_ASSERT during compilation in MSYS2 #747
Comments
To address the issue with #ifdef NK_NO_STATIC_ASSERT
#define NK_STATIC_ASSERT(exp)
#else
#define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
#endif This change introduces the |
The solution is not to disable static asserts, but to fix what's not working on this platform :) |
After further consideration, I would like to propose an alternative solution to address the issue with NK_STATIC_ASSERT in MSYS2/MinGW environments. #if defined(__MINGW32__) || defined(__MINGW64__)
// MSYS2/MinGW environment: skip static assertions
#define NK_STATIC_ASSERT(exp)
#else
// Default behavior
#define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
#endif |
As there is no existing compilation example for MSYS2, could you show how you invoke the compiler? I made a quick test on |
This is what my report looks like.
To calm down the errors, I used it as I wrote earlier and I leave it that way in my project. #if defined(__MINGW32__) || defined(__MINGW64__)
// MSYS2/MinGW environment: skip static assertions
#define NK_STATIC_ASSERT(exp)
#else
// Default behavior
#define NK_STATIC_ASSERT(exp) typedef char NK_UNIQUE_NAME(_dummy_array)[(exp)?1:-1]
#endif In the second case, the macro forces a compile-time check of the condition. If the condition (exp) is false (equals 0), the compiler will generate an error, because we are trying to define an array with a negative size, which is illegal in C. |
I recall that this topic was already discussed a few years ago. |
Indeed a negative size array is illegal in C, and that's the purpose of static assertions. That's why I ask you how you compile, which compiler is used and with which switches, to reproduce your error and find out why those sanity checks don't pass. I got the error, now I need the command line triggering this error. |
The problem here lies in the assumption that To make the library more flexible for such cases, I propose adding a conditional check for MSYS2/MinGW environments to skip static assertions when necessary. |
The issue is specifically related to the nuklear.h file, and the errors are not backend-dependent. While working on language bindings, I have carefully examined nuklear.h to ensure proper compilation of the sdl_renderer backend under both Linux and MSYS2. To achieve successful compilation, I had to make the following changes:
to:
With these changes, the compilation under Linux works perfectly, and everything runs as expected. Regarding MSYS2, I have described the issue above in detail. My suggestions and changes are provided for your consideration as an informational note. |
Actually
It's not making itmore flexible, but less robust and candidate to segfaults. The solution is more to understand why in your MSYS2 implementation, you fall on this case, because that should not occur. Once the origin of the problem is detected, we can add the various I just need the compilation command line (and/or Makefile), as well as your environment like Windows version to see if there is some peculiar context. |
Hi,
I am working on creating Nuklear bindings for xBase family languages. During compilation in MSYS2, I encountered the following errors:
The only way to bypass this issue and successfully compile the library and example was to comment out the following lines:
This allowed me to proceed with testing, but I understand that this is not a proper solution.
The problem occurs only in the MSYS2 environment – everything works correctly under Linux.
What can be done to address this issue?
The text was updated successfully, but these errors were encountered: