The register keyword in C language and the register keyword

Source: Internet
Author: User

The register keyword in C language and the register keyword

The variable modified by register in C language indicates that the variable is stored in the CPU register. Because the CPU access register is much faster than the access memory, the operation speed can be greatly improved. Note the following when using register.

1. The variable modified with register can only be a local variable, not a global variable. The CPU register resources are limited, so it is impossible for a variable to occupy the CPU register all the time.

2. The register variable must be a value acceptable to the CPU.

4. You cannot use the & operator to retrieve the address of the register variable.

5. register only requests register variables and may not succeed.


Keyword in C language of the Computer: What is register?

Register is a register type. That is to say, if a variable is defined, it is first considered to be put into a register, but there are so many registers. If it is used up, it will be placed in the memory. That is to say, the register type is defined with the definition, but not necessarily stored in the register.
 
Keyword in C language of the Computer: What is register?

Register
You can use the register modifier to declare that an object has an automatic life cycle. Therefore, register can only be used in the declaration of a function.
This keyword tells the compiler that the access to this object should be as fast as possible, and it is best to store it in the CPU register. However, the compiler does not necessarily do this.
In addition, when an object is declared as register, the address operator & is unavailable because it may be put into registers.
 

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