cgccllvm-gccc17c23

Plain C equivalent to Rust's unimplemented!() macros


Please note that this is not a question on C++, but on plain C

In Rust there is a handy macro unimplemented!() to let the runtime crash, to be used when a function is unimplemented.

I basically have resorted to assert (false) to emulate it in my C coding. Which doesn't work for release builds.

What I like about assert(false) over exit(-1) is that I end up in the debugger at the right spot.

I found Function not implemented macro? which looks good but the crash macro is not defined at least in my clang-gcc setup.


Solution

  • This is what the abort() function can be used for:

    Ref: https://en.cppreference.com/w/c/program/abort