tags:

views:

62

answers:

3

I use MSVC++ 2005 x64. Some code work incorrectly in release optimizing mode. So, I want to make test for that code. Problem is, my test code run only in debug mode. (I dont' want mix test code in product code.)

So, Can I declare some part of code to compile as release optimizing mode in debug build? For example, like, __asm ... or something... __build_start(Release) int x = 0; .. do something .. __build_end(Release)

Thanks in advance.

+1  A: 

You can do it at a file level, if that helps. Right click on the file in solution explorer -> properties -> c++ -> optimisation, then set the optimisation level for that file.

1800 INFORMATION
A: 

"Release optimization" in Visual Studio is not so simple as you seem to be assuming. Here is a (probably incomplete) list of the VS optimization options. There are quite a lot of them, so hopefully you'll find the ones you want here.

http://www-01.ibm.com/support/docview.wss?us=993&uid=swg21265414

Anonymous Cow
A: 

My first suspect would be not the optimizer, but debugging with side-effects. Watch out for things like:


assert( ++i ); // assertions with actions
print_debug( "foo = %d", get_foo()); // function calls that are compiled out
#if _DEBUG
#   speed += 10; // kludges
#else
#   speed += 1000;
#endif
Nikolai N Fetissov