GCC does not have a sensual, static function is inline

Source: Internet
Author: User

When it comes to inline, maybe you're still parked more than 10 years ago even more than 20 years ago in the C + + code, C + + has inline keyword inline, and even used to distinguish it from c. C99 start C introduced INLINE,GCC than C99 early implementation of the inline support, VC c no keyword Inline,inline can only be used in C + +, but there is another keyword __inline, but if you want to compile GCC C code with VC, The CL complaint does not recognize inline, as long as the inline is defined as __inline in the precompiled macro.

There is also a noinline in the GCC compiler attribute, with the inline why a noinline is needed. No use of inline is equal to noinline. There are also always_inline properties. Because in practice, the definition of inline is not necessarily all inline, and the inner end is determined by the GCC compiler, but your declaration will affect its decision. Similarly you are not defined as inline, the function is not necessarily isolated inline, the compiler in the optimization will usually decide for you to inline a number of functions, regardless of the size of the function is small or large. The Noinline and Always_inline attributes are literally the same.

Just recently debugging FFmpeg code, encountered an example, used for illustration:

FFmpeg is a C code project.

Avformat_write_header is a function with only 10 rows, which is called other functions.

Init_muxer is a large, static function that is not defined as inline, but is inline with a function (Avformat_write_header) that is small in size.

GCC does not have a sensual, static function is inline

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.