Solved

VERIFY information

Posted on 2004-08-25
4
247 Views
Last Modified: 2010-04-01
Hello;

I need to obtain object validation from a release version of my code.

The reason being is that a certain library that I am using in my app -that is crucial to my app- has long long function names. Longer than 256 which is VC++6.0 max debug size. Executing from a debug build produces an assertion error.

So I read up and find that VERIFY will do something about validating objects during release mode. But what? As the help section describes that VERIFY macro does not produce any printed output in release mode and has type void return??????????? So what good is it?

Any other solutions or comments apreciated.

RJ
0
Comment
Question by:RJSoft
  • 2
  • 2
4 Comments
 
LVL 19

Expert Comment

by:drichards
ID: 11899714
Here's the definition of VERIFY:

#ifdef _DEBUG
...
#define VERIFY(f)          ASSERT(f)
...
#else   // _DEBUG
...
#define VERIFY(f)          ((void)(f))
...
#endif // !_DEBUG

As you see, in debug mode it is defined as ASSERT.  In release mode, the condition expression is left in the code.  This is useful if the calculation of the condition has side effects like changing variable values or something.  In this case you cannot simply remove the code from the release version like ASSERT does.  That is why VERIFY exists.

If you want debug information from the release version, you will have to define your own TRACE or ASSERT macros to achieve the desired functionality.
0
 
LVL 3

Author Comment

by:RJSoft
ID: 11902553
Hello drichards;

here's more points.

Know any examples?

I tried adjusting the debug flag. Why does this not cause assertion?

#define _DEBUG //turn on debugger flag temporary...
VERIFY(0);
#undef _DEBUG

RJ
0
 
LVL 3

Author Comment

by:RJSoft
ID: 11902654
My main objective is just to prove that a certain object is valid.

I have an object that is accessed by a different thread so there is some question as to it's validity. The object is a CDialog.

I see that each CObject has AssertValid function. Should I use this or the macros?


Also I would like to have a VERIFY/ASSERT equivalent for future development of my app since I can not compile cleanly with the debugger without removing the library.

RJ
0
 
LVL 19

Accepted Solution

by:
drichards earned 500 total points
ID: 11902941
>> I tried adjusting the debug flag. Why does this not cause assertion?
Because the macro definition was loaded back in the header file.  By the time you get to your line, VERIFY is already defined as ((void)(f)) and it is too ate to change it.

If AssertValid gives you the result you need, then that is an option.  Otherwise, you'll have to write your own macro that is defined the way you need in Release mode.  With AssertValid, you may need to override it in the object you care about to behave as you want.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now