Some may
not be clear about the concepts. I explain a little bit.
1. release version: the code is compiled for end user applications(your customers).
Settings in the make file look like the following
CFLAGS = -m64 -pipe -O2 -Wall
CXXFLAGS = -m64 -pipe -O2 -Wall
-O, O2 or O3 have to be included for optimizing the code. -g can not be included.
If you can not use gdb or ddd to your code, it often means that you compile your code
for release, not for debugging.
2. debug version: the code is compiled for finding bugs(using gdb or ddd).
typical settings in Makefile are as follows
CFLAGS = -pipe -Wall -W -g -DDEBUG
CXXFLAGS = -pipe -Wall -W -g -DDEBUG
-g has to be included. O2 or O3 can not be included. If -g is not included, you will not be able to use gdb or ddd.
release version code runs about 2 times faster than debug version. Therefore, never send a debug version to your customers or your bosses because it is slow.
If you want to write some code only for debug version(like print some stuff), do the following:
#ifdef DEBUG
cout << "print results "<< endl;
#endif
print results will not appear in release version.
[ 此贴被steinlee在2009-01-24 00:52重新编辑 ]