Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

Are vararg calls binary-compatible with cdecl calls excluding the ellipsis?

joseph-krahn
New Contributor I
210 Views
Is it reliable to call a vararg function by prototyping it as a cdecl function without the ellipsis? It can be useful to call a C library vararg function from a language that doesn't support varargs. Often, varargs are a string-formatting convenience, and they can instead be passed a formatted string as the last non-optional argument, if it has no printf syntax.

My understanding is that the extra optional arguments will go on the stack, but is it essentially identical to a regular cdecl function if it is called wiothout any extra arguments. Is this inherent in the CDECL specification, or are there platforms where vararg calls handle arguments differently?
0 Kudos
0 Replies
Reply