C语言调试的四种方式

一. 编译器警告:

1. 默认, 编译器不生成所有警告。

2.使用 gcc -Wall

二. printf语句

1.Print to stderr instead of stdout

        •fprintf(stderr, ….)

三. assert

"assert" macro provided by standard library

        •Prints error message to stderr and terminates execution if assertion fails

四. 调试工具 gdb

        •By adding “-g” option to your cc/gcc compile & link commands 
        •Better yet, add “-g” to the CFLAGS variable defined in Makefile 

 

你可能感兴趣的:(C)