Use predefined macros commonly used in ansi c and Microsoft C ++

Source: Internet
Author: User

_ File __ Source File Name For example Xxx. cpp
_ Line __ CodeThe row number in the source file.
_ Date __ The source file completion date is shown in figure Aug 17 2011
_ Time __ The source file completion time is shown in figure 19:31:13
_ Timestamp __ The time when the source file is completed, as shown in figure Wed Aug 17 19:27:36 2011


For example, the memory allocation functionMalloc ()The above macro is used in a version

# DefineMalloc(S)_ Malloc_dbg(S,_ Normal_block, _ File __, _ line __)

You can alsoProgramUsed in_ File __And_ Line __To determine which file has an error.:

Char *Pszfilename= (Char *)Malloc(Max_path* Sizeof (char ));

If (Pszfilename=Null)

Printf("Error in % S % d \ n",_ File __, _ line __);

Of course, the actual program is mostly used_ File __And_ Line __After the error is quickly located, the system does not directly output the error, but uses another programEmailFeedback to developers.

 

Pair _ File __ It can be easily converted Wchar_t Type, Msdn Here is an example:

# DefineWiden2(X) L## X

# DefineWiden(X)Widen2(X)

# Define_ Wfile __ Widen(_ File __)

Wchar_t*Pwsz=_ Wfile __;

 

Hong Zhong#And##Will open another article.

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.