Note/C C++

[C++] inline

유니_ 2022. 3. 4. 16:23

https://stackoverflow.com/questions/8885665/c-pointer-to-inline-function

 

C: Pointer to inline function

I have a static inline function defined in an H file, and at one point in a C file, I'm assigning a pointer to the function, something like this: foo.h: static inline void frobnicate(void) { //

stackoverflow.com

======================================

Remember that inline is only a suggestion to the compiler 

=======================================

Inline calls are not as powerful as you might think.

This is a good discussion
http://www.parashift...-functions.html
The most important thing to be aware of is that a request to have the compiler inline something is not always going to be respected.
Also a good compiler will inline things even if you don't ask for it if they can see inline would be a good idea.

There are several ways to designate that a function is inline, some of which involve the inline keyword, others do not. No matter how you designate a function as inline, it is a request that the compiler is allowed to ignore: it might inline-expand some, all, or none of the calls to an inline function.

So they are less different to 'normal' functions than it is possible you might think they are.