How to elegantly implement a series of functions in different type versions using pure C?

后端 未结 5 697
北恋
北恋 2020-12-30 09:53

I want to write several functions that are only different in the types of arguments. I know C++ has template to handle this problem well (not very well yet thou

5条回答
  •  情深已故
    2020-12-30 10:21

    I would also propose Solution 4: write a code generation tool.

    Pros:

    • result is a clean debuggable code;
    • unlimited configurability to your needs (if you have time of course);
    • long-term investment to a dev's toolset.

    Cons:

    • takes some time, esp. at start, not always sutable for write-once code;
    • complicates build process a bit.

提交回复
热议问题