Is it a good idea to use varargs in a C API to set key value pairs?

前端 未结 7 2653
情书的邮戳
情书的邮戳 2021-02-20 11:47

I am writing an API that updates a LOT of different fields in a structure.

I could help the addition of future fields by making the update function variadic:

<         


        
7条回答
  •  自闭症患者
    2021-02-20 12:23

    I'd take a long hard look at any "update" functionality designed to be used externally (or even internally) which uses the same function to update many different fields in a structure. Is there a specific reason why you can't have discrete functionality for updating the fields?

提交回复
热议问题