help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to separate the implementation of inline functions?


From: Sean McManus
Subject: Re: how to separate the implementation of inline functions?
Date: Fri, 17 Sep 2004 19:50:06 -0700

> Not sure what you mean, please clarify with code (I'm gonna be away for 
> for
> few days).
>
> As you'll be aware from C (and "register") "inline" is merely a hint that
> compiler ought to do "stuff". GCC is better at this than most - a good
> example of "inline failures" is borland (stonkingly fast compiler but pays
> for it in this respect). Same applies for C++ I'm afraid - "inline" is
> today's "register". Aka - the fact "inline" is in the C++ vocabulary means
> absolutely nothing - compiler is at liberty to do as it will.

I can get inline to work successfully, but only when it's in the .h file 
along with the class declarations, for example

class myClass { // this works
    inline void myFunc() { ... } //... do something inline
};

// the code below does not work in g++, but it should as far as I know
class myClass { // in the .h
    inline void myFunc();
};

void myClass::myFunc() { // in .cpp
    // ...do something inline
}

It gives the warning message
warning: inline function `void myClass::myFunc()' used but never defined

undefined reference to `myClass::myFunc()'

It looks like this is causing a linker error.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]