问题描述
我有一个可变参数函数,它接受一个浮点参数。为什么不工作?
的va_arg(阿根廷,浮动)
的对应 ...
函数的参数的推荐的传球前你的可变参数函数。 字符
和短
都提升到 INT
,浮动
提升为双击
等
The reason for this is that early versions of C did not have function prototypes; parameter types were declared at the function site but were not known at the call site. But different types are represented differently, and the representation of the passed argument must match the called function's expectation. So that char and short values could be passed to functions with int parameters, or float values could be passed to functions with double parameters, the compiler "promoted" the smaller types to be of the larger type. This behavior is still seen when the type of the parameter is not known at the call site -- namely, for variadic functions or functions declared without a prototype (e.g., int foo();
).
这篇关于可变参数函数(在va_arg)不使用float工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!