rahuljn Posted August 25, 2014 Report Posted August 25, 2014 Hi Folks With C++ assert statements it is possible to disbale all assert() statemenets using NDEBUG macro. Is it also possible to do the same for sc_assert() ? Thanks Quote
Philipp A Hartmann Posted August 25, 2014 Report Posted August 25, 2014 Yes, defining NDEBUG also disables the sc_assert statements in the SystemC proof-of-concept implementation. Having said that, I don't think it is a good idea to do so globally. You usually want your simulation to reliably abort in case of an error/bug, instead of running into arbitrary undefined behaviour. I would recommend to leave assertions active by default until profiling proves that (specific) assertions have a significant performance impact. In such cases, selectively disable only these assertions in optimized configurations. /Philipp maehne 1 Quote
rahuljn Posted August 26, 2014 Author Report Posted August 26, 2014 Hello Philipp With following example, where I have #define NDEBUG, the sc_assert is still executed. #include "systemc.h"#define NDEBUG SC_MODULE(trial){ public: int i; SC_HAS_PROCESS(trial); trial(sc_module_name name){ i=10; sc_assert(i!=10); }}; int sc_main(int , char**){ trial et("et"); sc_start(); return 0;} Thanks Quote
Philipp A Hartmann Posted August 26, 2014 Report Posted August 26, 2014 The same would be the case for a plain C assert: #include <cassert> #define NDEBUG int main() { assert( false ); } I'll leave the solution as an exercise for the reader. ;-)(Hint: look for the word "before" in the link above.) /Philipp Quote
rahuljn Posted August 26, 2014 Author Report Posted August 26, 2014 Thanks Got the point. Thanks again. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.