Solved

VERIFY information

Posted on 2004-08-25
4
249 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 114
Dynamically allocate memory 9 56
Unresolved External Symbols 3 68
max float value 3 26
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

920 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