0

I'm going through a c++ h/cpp pair and inlining some functions to speed up my code. This is actually just c, there are no classes involved. I can't see any difference, but for some of these functions I can inline the header definition and/or the cpp code and get no LNK2001 error ... and I can tell the compiler is inlining now and was not before, because the executable gets bigger after inlining. For other functions, I can't inline at all without getting LNK2001, which I know means I need to put the whole function in the header. All these functions are being called from the same (other) translation units. Why don't I get LNK2001 error for all of them?

I'm pretty sure this is not answered elsewhere ...

dts
  • 125
  • 1
  • 10
  • Possible duplicate of [What Does It Mean For a C++ Function To Be Inline?](https://stackoverflow.com/questions/156438/what-does-it-mean-for-a-c-function-to-be-inline) – Retired Ninja Dec 23 '17 at 00:24
  • Have a read, __inline__ no-long means "please expand this function inline ": _"the meaning of the keyword inline for functions came to mean "multiple definitions are permitted" rather than "inlining is preferred"_: http://en.cppreference.com/w/cpp/language/inline – Richard Critten Dec 23 '17 at 01:13
  • I understand that ... that's why I made it clear that these functions ARE being inlined by the compiler, with no link error, even though they are not defined in the header ... and they were NOT being inlined before. – dts Dec 23 '17 at 01:24
  • are some of the functions being called before being defined in the code? That could potentially cause the compiler to throw the error. recommend running through MSDN's checklist of potential causes for the LNK2001 on their older documentation page at https://msdn.microsoft.com/en-us/library/f6xx1b1z.aspx. – Anson W Han Dec 23 '17 at 01:31
  • I know why the error is thrown, when it is ... what I want to know is why the error is NOT thrown, when it isn't. – dts Dec 23 '17 at 01:41

0 Answers0