Variable Parameter macro

Source: Internet
Author: User

Printing and debugging are inevitable in our development and testing phase. printing information needs to be removed when the release version is generated. We can use Conditional compilation to solve this problem, the specific method is as follows:

# Ifndef DEBUG_2012_06_06
# Define DEBUG_2012_06_06
# Endif

# Ifdef DEBUG_2012_06_06
# Define myPrint (str ,...){\
Printf (str, ##__ VA_ARGS __);\
# Else
# Define myPrint (str ,...)
# Endif

In this way, we use our own myPrint macro in the place where the output is printed, just like using the printf function,

To generate the release version, you only need to note # define DEBUG_2012_06_06 to remove all of our print information!

Related 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: 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.