Q:

How do I optimise a debug DLL to minimize debug checks in VC6?

I've been assigned to a large legacy project, which can only be deployed in debug version, due to various historical (and stupid) reasons. As one might expect, there are some performance issues.
The project is written in C, Visual Studio 6 (yes, that old). I'm looking for ways to minimize the impact of "everything is in debug version". Are there any compiler or linker options which would minimise the amount of debug code injected into the final binary? Or is there an external utility which could strip some of it later on?
(I know this is basically a silly question, and that we're supposed to switch to release, but trust me, this is completely out of my control..and it kills a part of my soul virtually every day.)

A:

First of all, you should list all the differences between the debug and the release versions and try to identify the things that you can change and the things that you cannot.
Then just change all the things you are allowed.
From the top of my head, if my memory serves me correctly:

Debug: link with debug DLLs. Release: link with release DLLs.
Debug: compile without any optimization. Release: compile with all optimizations.
Debug: compile with assertions (-D_DEBUG). Release: compile without assertions (-DNDEBUG).
Debug: compile/link with debugging symbols. Release: compile/link without debugging symbols (not really an impact on performance).
Any arbitrary changes the original developers made to the project configuration.

From all of these, only the first two should really be able to make a difference. The DLL because you depend on the debug DLL for some (silly) reason. And the second one because the optimizations can cause subtle bugs in the program to show themselves.

