Playing around with different ideas for generics/metaprogramming in C
Go to file
2023-12-31 15:42:44 +00:00
01_no_metaprogramming Implement manual version 2023-12-30 19:09:05 +00:00
02_macros Extract common macros to a header 2023-12-30 20:08:17 +00:00
03_xmacros Extract common macros to a header 2023-12-30 20:08:17 +00:00
.gitignore Update .gitignore 2023-12-31 15:42:39 +00:00
aliases.h Add aliases 2023-12-30 19:08:58 +00:00
build Add build scripts 2023-12-30 19:08:50 +00:00
compile Update build script 2023-12-31 15:42:44 +00:00
helper_macros.h Extract common macros to a header 2023-12-30 20:08:17 +00:00
README.md Update README.md 2023-12-31 01:44:05 +00:00

Generics/Metaprogramming in C

Exploring different ideas for implementing generics in C.

01_no_metaprogramming is the result of the code if implemented manually.

02_macros is an implementation that uses simple macros to define 2D and 3D vectors for different data types.

03_xmacros is an implementation that relies on X macros to allow for defining any N-dimensional vector for different data types. In this case, only 2D and 3D vectors were defined (for parity with the previous techniques), but it can be easily expanded to other dimensions.

General assessment of the different techniques

Technique Ease of implementation Readability Debugging Maintenance Extensibility Applicability to other problems Score (out of 5)
01_no_metaprogramming 3.00
02_macros 3.17
03_xmacros 2.33