473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can assert() hide debug dump out?

Hi,
I am using assert() to hide some debug dump out like this,

int dump(){
... some printf...
return 0;
}

then in my main code, I do this,
assert(dump() == 0);

I wished using this way to avoid that dump() is called in optimized
mode compile, but it seems it does not work! I still see the dump out in
optimized version.

Any idea?

Jul 22 '05 #1
2 1453
John Black wrote:
I am using assert() to hide some debug dump out like this,

int dump(){
... some printf...
return 0;
}

then in my main code, I do this,
assert(dump() == 0);

I wished using this way to avoid that dump() is called in optimized
mode compile, but it seems it does not work! I still see the dump out in
optimized version.

Any idea?


Make sure your "optimized mode compile" defines NDEBUG macro.

Victor
Jul 22 '05 #2
John Black wrote:
assert(dump() == 0);

I wished using this way to avoid that dump() is called in optimized
mode compile, but it seems it does not work! I still see the dump out in
optimized version.

Any idea?


assert() becomes nothing when NDEBUG is turned on. Look that up. It's a
system different from your compiler's optimization settings. Many
environments put all these details together into modes, such as Debug Mode
and Release Mode. But they are all different systems.

BTW if you put a whole bunch of assertions inside your dump(), and rename it
test(), then you'd have an in-vivo test suite. Running these over and over
again, and putting all conceivable requirements inside them, is a great way
to keep bugs out, and prevent the need to Debug.

--
Phlip
http://industrialxp.org/community/bi...UserInterfaces

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Stephen Tyndall | last post by:
I know the preprocessor is evil, but I'd like to know what's going on in the following code. The problem is when the num variable is used in the ASSERT macro inside main(). When running the...
10
by: linq936 | last post by:
Hi, I have many assert() call in my code, now I am considering to replace them with exception. The reason I want to do this change is that with the program going bigger and bigger, it is hard to...
11
by: David | last post by:
I am compiling C++ under both MacOsX and under Bloodshed Dev C++ on Windows XP. Because the console window disappears under Bloodshed when using the standard assert() via #include <cassert> I...
21
by: Giuseppe | last post by:
is assert() for debug only or not? Is it possible that I have seen the use of assert() in the Borland c++ 32 compiler (so assert is not for debug only)?
47
by: Rob Thorpe | last post by:
In general, is it considered bad practice to use asserts in production code? What about writing a macro that does the same as assert but continues to work regardless of the state of NDEBUG? I...
4
by: emma middlebrook | last post by:
I have a question regarding asserting ... here's some code: string GetAssertMessage() { ... prepare a message string and return it... } void SomeMethod() { ...
2
by: cody | last post by:
System.Diagnostics.Debug.Assert(); Hello??? A language should encourage programmers to heavily use the assert-feature, since it improves safety, stability, readability and maintainability of...
3
by: Brian Cryer | last post by:
It would be very handy to be able to stop the debugger on parts of code without having to explicitly set a breakpoint - either a "debugger.break" or "debug.assert" type of thing would do. I've not...
32
by: bingfeng | last post by:
hello, please see following two code snatches: 1. int foo (const char* some) { assert(some); if (!some) { return -1; //-1 indicates error }
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.