#static inline

30 messages · Page 1 of 1 (latest)

round umbra
#

using inline together with static is redundant, you should only use inline without static. Inline also gives a hint to the compiler to inline it so the probability is a bit higher but it says here: https://en.cppreference.com/c/language/inline

The compilers can (and usually do) ignore presence or absence of the inline specifier for the purpose of optimization.

so this usage of inline does not seem to be true when it usually gets ignored for that purpose. So why do David Blackman and Sebastiano Vigna use static inline here: https://prng.di.unimi.it/xoshiro256starstar.c
Vigna is a professor and Blackman a researcher, they published this implementation as the result of their research so i expect everything there to be there for a reason, so what is the reason they use static inline there instead of just static?

vapid inletBOT
#

When your question is answered use !solved or the button below to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

dusky spindle
sacred steppe
#

We are all victims of our habits sometimes, and i suspect this is a similar case.

Sometime ago when compilers weren't as good, i might of made a difference - today - not so much

#

As a sidenote - using inline on its own on functions with external linkage means something else entirely (I'm referring to the first line you wrote there. Not sure if you meant something else - just thought to make things clear)

round umbra
#

ok, thank you for your answers

vapid inletBOT
# vapid inlet

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity

round umbra
proven socket
round umbra
#

cppreference says compiler usually ignore the hint, so it is no hint

proven socket
#

I mean, it is still a hint even if it's ignored bing_shrug

round umbra
#

no it would be a hint if it actually increases the probabillity of being inlined

#

if it just gets ignored with no effect then it is no hint

#

cppreference says compiler do not care about if inline is there or not for the optimisation purpose they fully decide on their own, without even acknolegding the "hint"

#

so you would be left with inlines actual purpose which is obsolete when you use static

proven socket
#

#cpp-help-text message

round umbra
proven socket
round umbra
#

llvm is what i use. ok, then it seems the compiler does not completely ignore it. thank you

dusky spindle
round umbra
#

i also always use LTO

dusky spindle
#

me too ^^ but I mean, some people consider inline as a good thing

#

I still don't get their point

round umbra
#

but i was told some libraries do some cracked optimisation relying on a TU being independend and not seen by others. but since i am not able to do such things, i write my code assuming it gets compiled with LTO

#

but i wanted to learn about inline and all its uses

dusky spindle
#

yes I was going to say: maybe some compiled libraries cannot be inspected enough for the compiler to actually figure out