Function prototype with ellipsis [duplicate]

笑着哭i 提交于 2019-12-20 07:48:19

问题


I was wondering if the below function prototype is valid. It compiled fine, but the three period is kinda throwing me off and I couldn't find anything similar on Google.

void foo(int, ...);

Thanks!


回答1:


Yes, it's valid. In this example, ... creates a variadic function using the va_list mechanism. This is how variadic functions are implemented in C, and to some degree in C++ (though C++11's template parameter packs have rendered this mechanism obsolete).

Further reading: va_arg



来源:https://stackoverflow.com/questions/26768404/function-prototype-with-ellipsis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!