Key Points of C Programming habits

Source: Internet
Author: User

 

1 header file pre-defined

# Ifndef _ my_type_h __

# DEFINE _ my_type_h __

...... // Omit

# Endif

The first two rows are used to prevent repeated definitions when the header file is referenced for multiple times and an error is reported. The predefined character is a unique identifier. It is named in the format of two underscores (.) and two underscores. This macro definition is often used to controlCodeWhether the method is compiled.

2 volatile and idata keywords

Volatile uint8 variablea;

Volatile uint8 idata variableb;

The keyword volatile is used to tell the compiler not to optimize the operations on this variable. If you perform a series of replication operations on a variable, if it is a common variable, the compiler may think that the previous assignment is useless, but only the last assignment operation is retained; however, we may use a series of value assignment operations to output a waveform.

The idata keyword is the key word in keilc, which assigns the variable to the ram keyword with a height of 128 bytes. the compiler will give priority to the ram keyword with a lower 128 bytes, that is, even if idata is added, it is not always possible to allocate a variable in the upper 128 bytes.

However, if the variable exceeds 128 bytes without using idata, the compiler reports an error of insufficient Ram.

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.