C: Unspecified number of parameters - void foo()

前端 未结 4 1314
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-06 06:38

I read here that in C void foo() means a function foo taking an unspecified number of arguments of unspecified type.

Can anyon

4条回答
  •  温柔的废话
    2020-12-06 06:59

    This literally means that you are not telling the compiler what arguments the function takes, this means that it will not protect you from calling it with any arbitrary set of arguments. You would need to say in the definition precisely what arguments are actually taken for the function to be implemented however.

    You could for example use this if you were generating a header file to describe a foreign function in external code, however you did not know what the function's signature actually was, it would still then be callable using your header but if you provide the wrong arguments in the call results are undefined.

提交回复
热议问题