Macro definition, const variable, and enumeration

Source: Internet
Author: User


1. macro definition is expanded in the preprocessing phase; cnost variable is used in the compilation and running phase

2. The macro definition has no type and does not check any type. It only expands. The variable modified by const has a specific type and is executed during compilation.

3. The macro defines how many times a file is expanded and no memory space is allocated. The variable modified by const will allocate space in the memory.


1. enumeration is a constant, but the macro definition is not a constant.

2. Enumeration constants are one type of entities, but macro definitions are not entities.

3. enumeration has a type, but the macro definition has no type. Enumeration and common variables have scopes and values, but the macro definition does not. It is a preprocessing replacement.

Macro definition, const variable, and enumeration

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.