LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Are ASSERT() supposed to disappear under RELEASE mode?

How can I stop ASSERT() or assert() calls from killing my application's timing by removing its user prompt?
0 Kudos
Message 1 of 7
(3,728 Views)
Hello

Technically, you should'nt be getting assertions in code in the first place. But to get rid of the assertions during release, you need to have NDEBUG defined. Add the following code to the top of code (before the includes)

#define NDEBUG
#ifdef _CVI_DEBUG_ //If the build mode is Debug
#undef NDEBUG
#endif

CVI doesnt do the define automatically.
Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 7
(3,728 Views)
Thank you for you response. However, isn't the purpose for DEBUG and ASSERT() different?

These two examples should have same effect (_DEBUG for VS7 or NDEBUG for CVI):
main() {
int i=0;
assert(i!=0); }
and
main() {
int i=0;
#ifdef _CVI_DEBUG_
if (i==0)
MessagePopup( "exception occurred", "i==0");
#endif
}

So should I replace all my ASSERT() with <#ifdef _CVI_DEBUG_> ? Or wrap all my ASSERT() with it?
0 Kudos
Message 3 of 7
(3,728 Views)
actaully, the assert() macro is already bound by the NDEBUG define (which is how ANSI defines assert). You can check this by right-clicking on the in assert() and choosing "Go to Definition". So if NDEBUG is defined, assert() wont give you the pop up messages anymore. So with this

#define NDEBUG
#ifdef _CVI_DEBUG_ //If the build mode is Debug
#undef NDEBUG
#endif

Whenever you build using Debug mode, _CVI_DEBUG_ ( this is preset in CVI) gets defined and since we want asserts in debug mode, we undefine NDEBUG

I hope this helps

Bilal
Bilal Durrani
NI
0 Kudos
Message 4 of 7
(3,728 Views)
It sounds like _CVI_DEBUG_ is only defined if I am in "Configuration=DEBUG" mode.

However, when my workspace is under "Configuration=RELEASE" mode, and I do a workspace rebuild (checking RELEASE files), the assert() still causes a popup message.

Is there a setting that I need to perform so this assert will not popup if I am in RELEASE mode?
0 Kudos
Message 5 of 7
(3,728 Views)
yes

paste the ifdef statements before the includes in your C file and that should take care of the problem.
Bilal Durrani
NI
0 Kudos
Message 6 of 7
(3,728 Views)

static void CVICALLBACK fnDeferredReceive (void *data)
{

ClientInfoPtr clientInfoPtr = (ClientInfoPtr) data;

char dataBuf[256];
int bytesRead, dataSize, bytesToRead, tcpErr = 0, iReturn,iTotalByteRxvd=0,i ;
unsigned short uTotal =0,uTotal1=0,index=0;
assert (clientInfoPtr->readingData == 1); 

 

while (bytesToRead > 0)
{
 ------------------------------

 

 

please help me bfore im using asset in server side not giving eror,now my assert giving eror beace in client side im clientcpwrite doing 10 times....if i comment assert time out eror coming please help me

0 Kudos
Message 7 of 7
(3,204 Views)