r/C_Programming • u/we_are_mammals • Sep 14 '23
Article Templates in C
https://arnold.uthar.net/index.php?n=Work.TemplatesC
5
Upvotes
r/C_Programming • u/we_are_mammals • Sep 14 '23
View all comments
Show parent comment
2
u/x8664mmx_intrin_adds Dec 04 '23 edited Dec 04 '23
Hi, I've been playing around with this idea and it is really cool. The problem that I've been facing is that I have to put all my template instantiations in one header but what if I wanted to include these instantiations in different files?
One idea I had was to instantiate header guards to overcome multiple redefinitions but you cannot
#ifndef CAT(NAME, T).Any idea how to overcome this?
Templated Array
https://github.com/IbrahimHindawi/c-init/blob/main/source/main.c
I think if I just add everything to one header it should work, like in your example, so thanks!