Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VERIFY information

Posted on 2004-08-25
4
Medium Priority
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

609 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