1

I've found this answer about static inline functions in C headers, but I'm curious why would anyone add static inline functions in C++ headers.

Isn't inline enough to handle eventual linker errors when the compiler doesn't inline the function?

Does static do any harm in this case, like generating a definition in each cpp file that includes that header?

Mircea Ispas
  • 20,260
  • 32
  • 123
  • 211
  • This is about variables, but since linkage is really about names the answer is the same: https://stackoverflow.com/questions/58101044/is-there-any-sense-to-declare-static-global-variable-as-inline – StoryTeller - Unslander Monica Jul 13 '21 at 12:12
  • [Should one never use static inline function?](https://stackoverflow.com/questions/10876930/should-one-never-use-static-inline-function) – Evg Jul 13 '21 at 12:14
  • note that the question you've linked to is for `c`, the rules in `c++` are different – Alan Birtles Jul 13 '21 at 12:16
  • @AlanBirtles yes, I wrote this in the question and I want to learn about the C++ rules – Mircea Ispas Jul 13 '21 at 12:18

0 Answers0