Conditional based on variable type?

You should go for separate.h and .cpp

Even if you guard for the include, that is still per compilation unit and you could inject your functions many times if your project has multiple files needing that .h

Then at link time the compiler will complain of multiple definitions of the functions.

I did have a shot at splitting them up, but the templates came around to bite me in the behind. After a bit of research, you can't define templates in CPP files. I did read that leaving the definitions for the template can bloat your code size (although I don't know enough to know why). Although it does solve the issue. The other solution was something to do with defining all of the template specialisations that will be used specifically inside the cpp. Which if you ask me, kind of defeats the point of using templates in the first place, no? To avoid function overloads? :smiley:

The template definitions and function prototypes go in the .h file. The function implementations go in the .cpp file.

Here we are then! LCDCenterAlign.zip (16.6 KB)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.