google / styleguide

Style guides for Google-originated open-source projects
https://google.github.io/styleguide/
Apache License 2.0
37.01k stars 13.28k forks source link

Inline function defintion error #799

Open Mq-b opened 6 months ago

Mq-b commented 6 months ago

The original description is unclear:

You can declare functions in a way that allows the compiler to expand them inline rather than calling them through the usual function call mechanism.

I think it should be emphasized that defining inline functions, whether with the standard C++ keyword 'inline' or some other compiler extension, is just a 'suggestion'. The original text seems unclear.

The compiler can inline a function whether or not it is defined inline.

cppreference:

Since this meaning of the keyword inline is non-binding, compilers are free to use inline substitution for any function that's not marked inline, and are free to generate function calls to any function marked inline. Those optimization choices do not change the rules regarding multiple definitions and shared statics listed above.

Inline variables eliminate the main obstacle to packaging C++ code as header-only libraries. (since C++17)


In the previous Microsoft documentation, there was also some discussion of inline functions:

https://github.com/MicrosoftDocs/cpp-docs/pull/4823

google-cla[bot] commented 6 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.