Which header file? (Both `.hpp' and `.h' are often used for header files.)
I'm assuming some things about your files since I don't know about the difference between .h and .hpp files.
should be sufficient. You will need to replace the two spaces of indentation with a SINGLE TAB CHARACTER; you must use a tab.
I'll leave this here: it's a pain in the ass to have to update the makefile every time you add an #include, change the name, or add a file. This can be automated. The alternative is having to do clean builds all the time, since you'll invariably forget to add some header file as a dependency of some source file.
Edit:
you want a clean target, too; yours is fine, with two exceptions -- we want to ignore errors, and clean is not a file we can create. Replace the indentation with a tab.
My issue is that every time I try to compile, I get a massive amount of errors basically all of the form
"error: shadows template parm 'class V' "
or
"error: declaration of 'class V'
Even though I have my #ifndef and everything, I have my endif,
and there are NO double declarations of templates anywhere, so I assumed it would be a linkage error, and this new makefile does not seem to fix that. Am I on the right track to solve this?
No, that's a compilation error.
If it was a linker error, that should have been reported in the message as coming from LD or whatever your linker's name is (I'm assuming you're using the GNU toolchain; that wasn't specified).
You really should show the code that actually produces the errors. It will get you better answers.
Regardless, this is enough for me to have a guess at the problem:
Hashtable.hpp contains template member function implementations. Normally these files end in a tpp, ipp, or similar extension, but that's besides the point.
Specifically, I guess your .hpp file contains code like:
The use of and K of V shadow the Hashtable's template parameters. some_function should not be declared as a template member function, because it isn't one. K and V are already visible.
Yes, I apologize I should have included that. But yes you are exactly right about the format of the hpp file. The problem is it was given to me and I am not supposed to edit the function definitions, So I was hoping the problem was elsewhere
If you can edit hashtable.h, you can change the name of the class template parameters (e.g., to T and U) to get it to compile, and the declarations to reflect the fact that they are template member functions.
That's certainly not the best solution, but it's possibly workable.
OP wanted the result to be named "hash.x", not "driver".
I don't think there is a way to do that using only implicit rules.
Also (at least in GNU Make) the first target to appear is the default, and "all" should probably be marked as a .PHONY target just in case there happens to be a file named "all" in the CWD.
Assuming G++ or Clang, we can make it more general: