Archived

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

inline keyword in VS C++ 6

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

No. But you can use .inl files to achieve much the same effect.


/// A.h

#ifndef A_H
#define A_H

class A
{
public:
inline void foo();
};

#include "A.inl"
#endif




/// A.inl

void A::foo()
{
...
}



"Sneftel is correct, if rather vulgar." --Flarelocke

Share this post


Link to post
Share on other sites
One side note; you can specify the inline directive just in the .inl file, making your header files cleaner.

One tip; Here''s a technique that you will allow you to inline only in release mode saving precious debug compile time. This is especially useful for large projects. I know compilers usually don''t inline in debugmode anyway but they do have to parse all the .inl files which can be easily prevented.


/// A.h

#ifndef A_H
#define A_H

class A
{
public:
void foo();
};

#ifndef _DEBUG
#include "A.inl"
#endif

#endif




/// A.inl

inline void A::foo()
{
...
}

/// A.cpp

#include "A.h"

// Compile inline functions

#ifdef _DEBUG
#define inline
#include "A.inl"
#endif





-------
The problem with common sense is that it is never common.

Share this post


Link to post
Share on other sites