PDA

View Full Version : Inline functons causing Havoc



sunil.thaha
7th January 2006, 13:05
I couldn't figure it out why the inline setMessage( ... ) is causing link error ?
Please see the source attached

jacek
7th January 2006, 15:45
Calls to such functions are replaced* by those functions' code, therefore their definition must be accessible during compilation --- you can't add inline functions in the linking stage.

If you want to use inline methods you must move them to .h files.


Thread.h:14: warning: inline function `void Thread::setMessage(const QString&)' used but never defined

* Compilers threat inline keyword as a hint, so they might ignore in some cases.

sunil.thaha
11th January 2006, 13:08
Do u mean that i shouldn't write inline function in .cpp ?:confused:

jacek
11th January 2006, 13:13
Do u mean that i shouldn't write inline function in .cpp ?:confused:
Yes, unless you plan to use it only within that .cpp file.

sunil.thaha
12th January 2006, 07:22
Thanks A lot