PDA

View Full Version : About precompiled headers and template functions



tonnot
27th June 2011, 11:36
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

Santosh Reddy
27th June 2011, 12:02
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.

tonnot
27th June 2011, 12:08
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.-

Santosh Reddy
27th June 2011, 12:14
May be I did not understand you question :confused:

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)

tonnot
27th June 2011, 12:27
I have at my_class.h some templates .


template <class TT>
void W_stream::put (TT &value) {
int a=1;
}
Ok, I build the prog, run the program and a=1;
I re-write :

template <class TT>
void W_stream::put (TT &value) {
int a=0;
}
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

Santosh Reddy
27th June 2011, 12:36
Did you make sure, header file is present in project (.pro) file

wysota
27th June 2011, 13:06
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.