Subj : Re: what's difference between release and debug compiler in MS vc6.0? To : comp.programming From : Phlip Date : Sun Oct 09 2005 07:26 am wavelet wrote: > One of my friend write one program and run it in release > compile and debug compile mode. But the result from two > mode are different.It confused me a little. > > Does someone know what's the possible reason to cause > differnt run-result between release and debug compile mode? That's like asking, "I wrote two similar programs, with generally the same classes and lines, and I compile each with a different compiler. So why do they behave slightly differently?" Debug mode turns off a variable called NDEBUG, and turns on _DEBUG. Then code uses conditional compilation to expand various macros differently for each mode. Release mode reverses those variables, so things like assert() go away and don't compile. Programmers often put extra behavior into Debug mode, to validate the program's behavior, or provide special output like extra data in the log files. Then, the compiler uses different settings in each mode. Debug mode turns off optimizations and turns on the debugging output; Release mode reverses that. Compilers often provide different versions of their support libraries for each mode. All compiler settings have undocumentable features (commonly known as "bugs"), you get subtly different behavior for each kind of compile. So, put together, Debug mode and Release mode can have any number of differences. All are under the programmer's control. I occassionally turn on the debugging output in Release mode, so I can debug some weird situation - with the optimizations and without the extra assert() statements and such. So just the other day I was debugging legacy code, and could not figure out why the debugger could not show me certain variables. It seems the legacy programmer left the debugging output turned on in Release mode, and I didn't notice... -- Phlip http://www.greencheese.org/ZeekLand <-- NOT a blog!!! .