For more information, see WindowsProgramDebugging Everett N. McKay Mike Woodring translated by HE Jianhui Xu junjuan Dong Wei
Chapter 4 C ++ for debuggingCode
1. The pre-processing name is not in the symbol table. Therefore, you cannot use a debugging tool to check the pre-processing constant.
2. malloc only allocates memory. New also calls the object constructor. The comparison between free and delete is also true.
3. Any problems with the c ++ input/output stream can be detected at the time of compilation, and the input/output can be reloaded in any c ++ class.
4. Place all shared definitions and declarations in the header file. do not view the extern keyword in the. cpp file.
5./GZ compilation options. Automatic variables will be initialized during debugging.
6. Because most constructors can initialize their objects to a well-defined state, object initialization is usually not required. For example, cstring strtemp;
7. The maximum float error is defined by the flt_epsilon macro, and the double value is dbl_epsilon, both of which are defined in the float. h.
8. The virtual function of the constructor is not like a common virtual function. If a base-class constructor calls a virtual function, it actually calls the base-class version of the virtual function, instead of the version after the overload. Otherwise, if the base class calls the virtual function of the derived class, an access exception occurs because no data member of the base class has been constructed. If the constructor really needs a virtual function, use a separate initialization function.
Chapter 4 Use assertions
1. The assertion fails, but the assertion is not successful. Assertions cannot replace tests.
2. Custom assertions: The call stack is displayed in the message of the custom assertions macro created by logging and stackwalk functions (refer to callstacktest downloaded from the Internet)
3. The C Runtime function library and the MFC asserted macro display a message box with an asserted failure. However, this default behavior can be changed through _ crtsetreportmode, output to message box, output window, file, or any combination of these options
Chapter 4 Use trace statements
1. The buffer size of the Visual C ++ output window is limited. Therefore, if the speed at which the trace message data is generated exceeds the processing speed of the output window, data will be lost when the buffer is full. The solution is to add sleep (100) Similar sleep code to the high-peak zone.