在C函数的参数和功能用C重载的默认值 [英] Default values on arguments in C functions and function overloading in C
问题描述
转换一个C ++的lib到ANSI C,它看起来虽然ANSI C不支持默认值,函数变量还是我错了?
我要的是一样的东西。
Converting a C++ lib to ANSI C and it seems like though ANSI C doesn't support default values for function variables or am I mistaken? What I want is something like
int funcName(int foo, bar* = NULL);
另外,是功能ANSI C超载可能吗?
Also, is function overloading possible in ANSI C?
那就需要
const char* foo_property(foo_t* /* this */, int /* property_number*/);
const char* foo_property(foo_t* /* this */, const char* /* key */, int /* iter */);
当然可能只是他们的名字不同,但被用于C ++我还挺用于函数重载。
Could of course just name them differently but being used to C++ I kinda used to function overloading.
推荐答案
没有,标准C不支持任何。为什么你觉得你需要你的C ++ code转换到C?这可能会变得非常棘手 - 我还以为写的包装会去,如果你的C ++必须从C调用的方式
No, Standard C does not support either. Why do you feel you need to convert your C++ code to C? That could get quite tricky - I'd have thought writing wrappers would be the way to go, if your C++ must be callable from C.
这篇关于在C函数的参数和功能用C重载的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!