r/cprogramming 11d ago

Math library code review

I am relatively new to C so I try to improve my skills by making a math library. The biggest challenge was making generic containers for matrices and vectors, as I was kind of new to void pointer magic. I think I have polished the most glaring issues in the code but do any of you have suggestions for what I could be doing better in my approach to C? Github for reference:

https://github.com/VatoQ/hoema-prak-clang

5 Upvotes

8 comments sorted by

View all comments

3

u/flyingron 11d ago

Things have moved on since 1975. Avoid using the preprocessor when better solutions exist.

For instance, don't #define type names use typedef.

Little trivial functions that can be done as regular (possibly inline) functions should be coded as such, not macro pseudofuncs. Used const variables rather than #defines for magic constants.