Results 1 to 5 of 5

Thread: Inline functons causing Havoc

  1. #1
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Inline functons causing Havoc

    I couldn't figure it out why the inline setMessage( ... ) is causing link error ?
    Please see the source attached
    Attached Files Attached Files
    We can't solve problems by using the same kind of thinking we used when we created them

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inline functons causing Havoc

    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.

  3. #3
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inline functons causing Havoc

    Do u mean that i shouldn't write inline function in .cpp ?
    We can't solve problems by using the same kind of thinking we used when we created them

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inline functons causing Havoc

    Quote Originally Posted by sunil.thaha
    Do u mean that i shouldn't write inline function in .cpp ?
    Yes, unless you plan to use it only within that .cpp file.

  5. #5
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Inline functons causing Havoc

    Thanks A lot
    We can't solve problems by using the same kind of thinking we used when we created them

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.