C # tutorial # warning and # error Introduction

Source: Internet
Author: User

Xiaotian: I found a problem. You always use the # define declarative symbol on it, and it has not been revoked.

Laotian: Don't worry. Next let's look at two very useful preprocessing commands: # warning and # error. When the compiler encounters them, both warnings and errors are generated. If the compiler encounters the # warning command, the text content following the # warning command is sent as the warning content, and the compilation continues.

If you encounter the # error command accidentally. The message "# error" is displayed as the error message and the compiler stops compiling. Of course, the IL code will not be generated.

These two commands remind us of whether or not we used # define to do something wrong, and the use of the # warning command reminds us of what we have done. For example, the following is an example based on the previous pre-processing commands. Enter the following code in the above instance:

# If debug & debug1

# Error "Eldest Brother, what programs do you write if you are so abstract? This compiler is not interested in serving you! "

# Endif

# Warning "Dear user, this compiler is very dissatisfied with your poor looks! "

Press F5 for debugging, but an error and a warning will be given respectively. Effect 2-7

Figure 2-7 one error and one warning are prompted during compilation.

How about it? Although we hate, fear, and hate this scene the most when writing programs again, we did it on purpose!

As for how to do this, I suggest you go to a few friends who are studying together. After that, he accidentally finds a hidden location and adds the above example. It's interesting to keep it safe!

This article is a new one. For more information, see the source and author!

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.