Linking __inline functions/methods in VC++6.0

Started by
7 comments, last by Zorak 21 years, 6 months ago
Is there any way to work around the inline depth thingie in vc++6.0? The problem is that VC6.0 needs all the inline functions/methods in the header. I need them in a .cpp file or I will die out of code design sickness thingie. There must be a way to compile inline methods and let the linker find them even if they are in a .cpp file rather than the .h file. No? - Zorak - Neat Fella.
Domine non secundum peccata nostra facias nobis
Advertisement
No
no, but msvc7 offers "whole program optimization" which may give you that functionality.
hmmm....

// MyClass.h#ifndef MYCLASS_H#define MYCLASS_H#define INLINE(x)class MyClass{    MyClass();    INLINE(void MyInlineFunction());    // inlines    #define MYCLASS_INLINES    #include "MyClass.cpp"    #undef MYCLASS_INLINES};#endif// MyClass.cpp#ifndef MYCLASS_INLINES#include "MyClass.h"MyClass::MyClass(){    DoStuff();}// inlines#elseinline void MyInlineFunction(){    DoOtherStuff();}#endif     


Don't listen to me. I've had too much coffee.

[edited by - sneftel on October 19, 2002 2:38:28 AM]
Why do you have such a need for inline functions? You seem like you have a large amount, but inline functions are short, so it shouldn''t be much trouble to have them in the header. Have you profiled and seen that inlining all those functions would be A Good Thing (tm)?
quote:Original post by Neosmyle
Why do you have such a need for inline functions? You seem like you have a large amount, but inline functions are short, so it shouldn't be much trouble to have them in the header. Have you profiled and seen that inlining all those functions would be A Good Thing (tm)?


Its a vector class with a bunch of methods and asm functions to support it. And its getting big. Thanks for your help all.

- Zorak - Neat Fella.

[edited by - Zorak on October 19, 2002 8:02:36 AM]
Domine non secundum peccata nostra facias nobis
I always just done:


  // in the headerinline void aMethod(...);// in the cpp fileinlinevoid aMethod{...}  


It compiles fine and links okay but doesnt this work as an inline then?
It''ll (almost certainly) only be inline to functions in that same CPP file that come after it. And I''ve seen linker errors arising when trying to use such a function from another file.

[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]
Andy: your method works if only the .cpp file with the inline definition uses that header file. If that header is used by another class, your project won''t link.

This topic is closed to new replies.

Advertisement