We can add some LABEL to mark some debug message that need to be show up in "debug version".
Oppositely , we can disable these debug message for "release version"with the
same source.
========= Makefile===============================
ifeq ($(DEBUG),y)
CFLAGS :=$(CFLAGS) -DDEBUG
endif
=========compile command =========================
release mode:
make clean; make
debug mode:
make clean; make DEBUG:=y
出貨給客戶,就編release mode給他,如此一來他們不會看到任何message從terminal
跑出來
若是自己要debug 相同的code就編debug mode,方便自己看message
就不需要進去code在修修改改了
=======Source code example==========================
#ifdef DEBUG
printf ( "debug message" );
#endif
if debug mode , "debug message" will show up , and release mode doesn't.
為了整齊美觀,可以特地寫一個小function
把debug message 寫在裡面
就不會整篇code看到一大堆 #ifdef DEBUG
for example:
void debug_print_info_variable ( char *info , char *var)
{
#ifdef DEBUG
printf ( "%s , %s\n" , info , var );
#endif
}
.....
....
.......
source code:
src_child_status = g_match_info_fetch ( child_match_info , 6 ) debug_print_info_variable ("\nSTATUS= %s\n", src_child_status);
src_real_child_status = update_treeview_TransferDeviceStatus( src_child_status );
debug_print_info_variable ("\nREAL STATUS= %s\n", src_real_child_status);
沒有留言:
張貼留言