ARTICLE AD BOX
I'm using .tpp files to store template implementations.
However, modifying a .tpp file does not trigger recompilation, because Make does not generate an .o file from a .tpp source.
Still, these changes affect the compilation of .cpp files that include the corresponding .hpp.
How can I make Make recompile when a .tpp file is changed?
MRE.hpp
#pragma once #include <iostream> template <typename T> class MRE { T a; public: void write(std::ostream&); }; #include "MRE.tpp"MRE.tpp
template <typename T> void MRE<T>::write(std::ostream& os) { os << "initial message"; }TestMRE.cpp
#include "MRE.hpp" int main() { MRE<int> m; m.write(std::cout); std::cout << std::endl; }Initial Makefile
TestMRE: TestMRE.o $(CXX) $(CXXFLAGS) $^ -o $@ %.o: %.cpp %.hpp $(CXX) $(CXXFLAGS) -c $< -o $@Observed behavior
Running the program prints:
initial message
I change "initial message" to "final message" in MRE.tpp.
Running make prints:
make: 'TestMRE' is up to date.
Running the program again still prints:
initial message
612k36 gold badges525 silver badges882 bronze badges
5
