Home » U++ Library support » U++ Core » CHECK macro
CHECK macro [message #5993] |
Fri, 27 October 2006 03:26  |
exolon
Messages: 62 Registered: July 2006 Location: 53'21N 6'18W
|
Member |
|
|
Hi, I was wondering if anyone can explain the purpose of the CHECK macro defined in Core/Diag.h? Is it an assertion macro?
It's a very generic name, and since macros seem to have no scope or namespaces (I don't know much about preprocessor stuff since I don't use it much), it conflicts in my case with the unit testing library I use (UnitTest++). This means I either have to rename the macro in the testing library which doesn't seem right, or rename the one in Diag.h and wherever it's used. This is what I've done before, but I don't like having to do it every time I move to the next version of UPP. It causes trouble when I include Core/Core.h to use the String class, for example.
Does anyone have any ideas about handling this more easily?
|
|
|
|
Re: CHECK macro [message #5995 is a reply to message #5994] |
Fri, 27 October 2006 04:05   |
exolon
Messages: 62 Registered: July 2006 Location: 53'21N 6'18W
|
Member |
|
|
luzr wrote on Fri, 27 October 2006 02:41 | It is similar to ASSERT, but expression gets evaluated even in release mode (therefore you do not lose desired side effects - e.g. you can use CHECK to test the return code of some routine. If you would do it with ASSERT, routine would not get called in release mode).
|
So it's a sort of design-by-contract "defensive programming" thing?
luzr wrote on Fri, 27 October 2006 02:41 | I guess the simple thing to do is #undef CHECK before including your unit testing stuff.
|
Well, doing this caused a lot of errors since CHECK was redefined and some code in Core is trying to use it. It's not a big deal, I made a terrible sed script to do some of the replacements. And if, as you say, unit testing is a future consideration for U++ (a very good thing!!), I'll participate as much as my limited experience allows on that topic.
|
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 22:10:40 CEST 2025
Total time taken to generate the page: 0.00458 seconds
|