• 4783阅读
  • 4回复

differences of release and debug versions [复制链接]

上一主题 下一主题
离线steinlee
 

只看楼主 倒序阅读 楼主  发表于: 2009-01-24
— 本帖被 XChinux 执行加亮操作(2009-01-24) —
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重新编辑 ]
Looking for remote C/C++ and Qt 兼职
离线280923299
只看该作者 1楼 发表于: 2009-01-29
Is it totally same in debugging on VS Qt Integration? A little bit confused
离线steinlee

只看该作者 2楼 发表于: 2009-01-30
It is not same. If you debug your code, it is debugging mode(implies -g is used). For release, you need to switch to release mode to compile.

引用第1楼280923299于2009-01-29 09:00发表的  :
Is it totally same in debugging on VS Qt Integration? A little bit confused
Looking for remote C/C++ and Qt 兼职
只看该作者 3楼 发表于: 2009-01-30
#ifdef DEBUG
  cout << "print results "<< endl;
#endif


in Qt, we can simply use qDebug()<< "print results " to do this.
离线steinlee

只看该作者 4楼 发表于: 2009-02-12
nice to know this. Thanks. However, in parts of your code where no Qt is used, you can use
#ifdef DEBUG
---------
#endif

引用第3楼都市无名者于2009-01-30 10:48发表的  :
#ifdef DEBUG
  cout << "print results "<< endl;
#endif
.......
Looking for remote C/C++ and Qt 兼职
快速回复
限100 字节
 
上一个 下一个