The inline function contains static variables and whether multiple copies are generated during the call.

Source: Internet
Author: User

Inline int static_test ()
{
Static int I = 0;
...
}
Inline indicates the compile timeCodeCopy, there are multiple copies, but in the VC test, I only have one copy, then how the compiler implements:

 

1. Copying code is not necessarily a copy of C code. It can be a copy of compiled assembly code. While the function is in the code segment, the variable is in the data segment. Only the function part is copied. Static variables only store the address of the variable in the function section.

2. Static variables are not stored in the stack, but in the static data zone. They are stored together with global variables. They cannot be confused with local variables.

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.