From: "Kerilk (Brice Videau)" Date: 2022-05-13T02:45:29+00:00 Subject: [ruby-core:108538] [Ruby master Bug#18777] NDEBUG macro defined after including ruby.h Issue #18777 has been updated by Kerilk (Brice Videau). shyouhei (Shyouhei Urabe) wrote in #note-1: > This is intentional. Devs hate assertions. See also https://bugs.ruby-lang.org/issues/16837 . Thanks for confirming. Here is the workaround I use should anybody with the same issue needs a solution. ``` // Ruby 3+ bleeds NDEBUG // see https://bugs.ruby-lang.org/issues/18777#change-97580 #ifdef NDEBUG #include #else #include #undef NDEBUG #endif // DO NOT MOVE. If assert.h is included before ruby.h asserts will turn to no-op. #include ``` ---------------------------------------- Bug #18777: NDEBUG macro defined after including ruby.h https://bugs.ruby-lang.org/issues/18777#change-97581 * Author: Kerilk (Brice Videau) * Status: Closed * Priority: Normal * ruby -v: 3.0.2p107;3.1.2p20 * Backport: 2.7: UNKNOWN, 3.0: UNKNOWN, 3.1: UNKNOWN ---------------------------------------- Hello, When using ruby 3+, including `ruby.h` results in the `NDEBUG` macro becoming defined, which deactivates assertions. This simple (see attached `test.c` file) example illustrates this: ```C #include #include int main() { assert(0); return 0; } ``` I expect: ```bash gcc test.c ./a.out ``` To fail, and it does not. Commenting the `#include ` yields the expected result. I found several discussion in the issues regarding `NDEBUG` in Ruby 3+, but none seem to describe this particular behavior. Sorry if I missed something. Thanks. ---Files-------------------------------- test.c (79 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: