Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • @Heptic: the wording of the standard is somewhat ambiguous, but as I understand it, the compiler is always free to completely ignore any inline definition and fall back to an external one, which will obviously fail if there isn't such a definition in another translation unit... Commented Feb 24, 2012 at 12:19
  • @Heptic: my interpretation seems to be correct - see the accompanying example, ie C99 7.6.4 §8 Commented Feb 24, 2012 at 12:21
  • @Heptic: also, not all major compilers/linker work the way you describe - in addition to clang, gcc also respects C99 semantics if -std=c99 or -std=gnu99 is present... Commented Feb 24, 2012 at 12:48
  • touche. C99 standards agree with you. I can't see any logic behind their decision, especially in light of gcc/c++/msvc doing it correct, but that's a separate issue. Commented Feb 24, 2012 at 12:50
  • static inline implies that each translation unit gets its own copy of the function. This increases the size of the binary. inline make one function shared by all translation units. See also stackoverflow.com/questions/10847176 Commented Apr 1, 2020 at 5:42