i've been messing around with compiler explorer and in C if i pass a function pointer to a static inline function to another function inside the same translation unit then both msvc and gcc seem to inline the static inline function's body

my question is, how much can i rely on this behavior?

@eniko it’s a quite reliable performance optimization, if you want to make it actually guaranteed you can use __attribute__((always_inline)) (for clang/gcc) and __forceinline (for msvc)
@porglezomp isn't that for when you're calling them directly, not as function pointers?

@eniko oh right right my bad. 😅 Overapplied things I was reading lately.

It’s still reliable enough through function pointers in the same translation unit that I know this approach is a code style some people have been recommending for years. If the function you’re passing the pointers to is large and is called enough times with different arguments the compiler might stop specializing it/inlining it.