# Ifdef _ debug usage Summary

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.