1
# Ifdef _ debug
Virtual void assertvalid () const; // assert (assert) valid (valid, correct)
Virtual void dump (cdumpcontext & DC) const; // storage Context
# Endif
These two functions are used for debugging. The first function checks availability, that is, whether they are valid.
If the second function is not changed, the final call is cwnd: dump ();
Output Window class name, title name, and other information (in the output window)
# Ifdef _ debug
# Endif
This is Conditional compilation, that is, if the # DEFINE _ debug functions are compiled, otherwise they are ignored,
When you use DEBUG to generate a development environment (relative to release), the macro definition is automatically added, and these two functions are valid.
2
# Ifdef _ debug // determine whether to define _ debug
# UNDEF this_file // cancel the definition of this_file
Static char this_file [] =__ file __; // defines this_file to point to the file name
# Define new debug_new // define the new macro for debugging to replace the New Keyword
# Endif // end
If _ debug is defined, it indicates the compilation in the debugging status. Therefore, the definition of the two symbols is modified accordingly.
This_file is a global variable of the char array. The string value is the full path of the current file, in this way, when an error occurs in the program in the debug version, the code can be processed. This variable tells you which file has a problem with the code.
After _ debug is defined, the compiler determines that this is a debug. Compile the code between # ifdef _ debug and # endif. # UNDEF indicates clearing the current macro so that this_file is not defined. _ File _ is one of the six macros that the compiler can recognize in ansi c. # Define new debug_new
Debug_new locates Memory leakage and tracks file names.
//////////////////////////////////////// ////////////////////////////////
/// Another explanation
# Ifdef _ debug // If the status is debug
# UNDEF this_file // clear this_file
Static char this_file [] =__ file __; // defines this_file as // _ file _ (this is the full path name of the current file)
# Define new debug_new // define new as debug_new (this can detect problems such as internal/memory leakage, which is actually the debugging functions starting with CRT)
# Endif