Mentions légales du service

Skip to content

Mechanism to provide assert-like behaviour

GILLES Sebastien requested to merge 8_assert into main

assert are not supported natively by cppyy: the underlying cling is compiled with optimizations enabled, which trigger the NDEBUG macro, with which assert() macro does nothing.

In Xeus-cling, we managed to activate them nonetheless by undefining NDEBUG, which wasn't very safe but was good enough for our needs in C++ training session.

Same trick doesn't work with cppyy however.

@ldavid proposed to circumvent this by defining ourselves the assert macro. To avoid being superseded by the macro defined in or <assert.h>, we need to filter them out of the provided code.

I also added some mechanism to avoid spurious messages from cppyy:

  • One that says "compilation failed:" and is inaccurate here.
  • Another that says "Failed to parse C++ code" and was also inaccurate here.

Current modifications made #19 somewhat worse (we replaced an inaccurate error message by no message at all) but it's beyond the scope of current MR.

Closes #8 (closed).

Merge request reports