Define and inline keyword comparisons

Source: Internet
Author: User

Here we learn the usage of the Define and inline keywords, and their differences.

Define: Defines a macro that is processed at precompilation time, but simply replaces the string with no type checking .

The inline:1, inline keyword is used to define an inline function of a class, and the main reason for introducing it is to replace the macro definition in the form of the expression in C with the completion of the compilation phase . 2, inline function to do type security check , inline refers to the embed code, in the call function where not jump, but to write directly to the code there, for the short function, the inline function can be a certain increase in efficiency, and the C-era macro function compared to The inline function is more secure and reliable, at the expense of increased space consumption.


PS: Defining an inline function is only a suggestion to the compiler, but the final decision is the compiler, and if the logic of the function is complex (with cyclic recursion), then the inline fails. According to the Google programming specification, inline functions are typically below 10 lines and are logically simple.



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Define and inline keyword comparisons

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.