Results 1 to 7 of 7

Thread: About precompiled headers and template functions

  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default About precompiled headers and template functions

    When I make some modification in the code of a template function, I have to rebuild my project.
    This is related to precompiled headers (my templates are stored at a .h) ?
    Is there a way to re-build only the class I have modified ?
    (I'm using Qtcreator and Mingw)
    Thanks

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: About precompiled headers and template functions

    when using qmake (to that case any make), it will build only the changed files, if you change any header file, all the files which dependent (include directly / indirectly) on this header file will be built again. (You can customize this, by writing custom make file). Even precompiled headers header won't help if template header are changed, they are compiled again.

  3. #3
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About precompiled headers and template functions

    I promise you that a little change into the code of a template function is not taked into account. I need to rebuild.
    Whats happen ?
    Thanks.-

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: About precompiled headers and template functions

    May be I did not understand you question

    Do you mean, when you change the template header file, it is not compiled again? If yes make sure the head file is added the project file (.pro)

  5. #5
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: About precompiled headers and template functions

    I have at my_class.h some templates .

    Qt Code:
    1. template <class TT>
    2. void W_stream::put (TT &value) {
    3. int a=1;
    4. }
    To copy to clipboard, switch view to plain text mode 
    Ok, I build the prog, run the program and a=1;
    I re-write :
    Qt Code:
    1. template <class TT>
    2. void W_stream::put (TT &value) {
    3. int a=0;
    4. }
    To copy to clipboard, switch view to plain text mode 
    Ok, I build the prog, run the program and a=1;
    I have rebuild or clean+build to the program runs as I want : a=0;
    It only happen with template funtions. Changes made at any other place are take into account.
    Thanks

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: About precompiled headers and template functions

    Did you make sure, header file is present in project (.pro) file

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: About precompiled headers and template functions

    Precompiled headers are meant to be used with files that do not change. If your templates are being modified, remove their files from precompiled headers definition.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. VSAddin bug with precompiled headers?
    By indiocolifa in forum Newbie
    Replies: 3
    Last Post: 28th May 2013, 07:48
  2. Replies: 4
    Last Post: 25th June 2010, 10:21
  3. Qt Creator Precompiled Headers and Qt Creator on mac (g++)
    By mrshoki in forum Qt Tools
    Replies: 1
    Last Post: 22nd April 2010, 20:51
  4. Precompiled headers
    By Benjamin in forum Qt Programming
    Replies: 1
    Last Post: 4th December 2008, 15:48
  5. Sharing precompiled headers
    By magland in forum Qt Programming
    Replies: 0
    Last Post: 15th November 2007, 10:49

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.