• ### Popular Now

• 11
• 27
• 9
• 20
• 31

#### Archived

This topic is now archived and is closed to further replies.

# Linking __inline functions/methods in VC++6.0

This topic is 5628 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

No

##### Share on other sites
no, but msvc7 offers "whole program optimization" which may give you that functionality.

##### Share on other sites
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]

##### Share on other sites
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)?

##### Share on other sites
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]

##### Share on other sites
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?

##### Share on other sites
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 ]