# Error and # progma

Source: Internet
Author: User

1, # error

During program compilation, a compilation error occurs when # error occurs. What should I do if it is a compilation error? The purpose is to ensure that the program is compiled as you imagined. The following is an example: a program usually contains many preprocessing commands.
# Ifdef xxx
...
# Else
...
# Endif
When the program is large, some macro definitions are usually specified externally (such as makefile) or in the system header file. When you are not sure whether XXX is defined currently, you can compile it as follows:
# Ifdef xxx
...
# Error "XXX has been defined"
# Else
...
# Endif
In this case, if an error occurs during compilation, XXX has been defined is output, and the macro XXX has been defined. This function can also be used as an error exit warning during compilation.

2, # progma

In a word, # pragma is a macro extension defined to make the C or C ++ program compiled by the compiler fully compatible with machine hardware and operating systems, # pragma is related to a specific compiler.
I. # pragma description (directives)
Each execution of C and C ++ programs supports some unique features of the host or operating system. Some programs, for example, need to precisely control the memory area where data is stored or control the parameters received by a function. # Pragma indicates that the compiler provides a method for compiling on different machines and operating systems to ensure full compatibility between C and C ++. # Pragma is defined by machines and related operating systems and is usually different for each compiler.
Ii. Syntax)
# Pragma token-string (feature string). A feature string is a series of characters that provide instructions and compilation comments to a specific compiler. The symbol (#) must be the first non-space character in the line where Pragma is located; # any space character can be entered between the symbol and Pragma. After # pragma, It is a preprocessing feature character that can be parsed by the compiler. Generally, # pragma is a macro extension. If the compiler finds a pragma that it does not know, it will give a warning but continue compiling. Pragmas can be used in condition declarations to provide the latest functional preprocessing programs, or to provide compiler-defined execution information.

 

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.