Monday, February 12, 2007

Update on Inlines

Last night I discovered that it was inline functions that caused my linking problems though at the time I wasn't sure why. I've googled around a bit and now the cause has come clear. The process of inlining is usually done at compile time (not link time) and for the compiler to be able to inline the function it must be able to see its internal definition. In my code I just so happened to place these inline functions in the .cpp files. Had I placed them in the header file, it probably would have been fine. However, the reason I put them in the cpp file in the first place is that I specifically wanted to avoid any implementation code, no matter how minor, in the header file. So I'll leave it as it is, I'm sure the compiler will do a fine optimization job anyway.

No comments: