我读过
但是,有一个问题我还没有找到答案:使用extern "C" (例如,在尽可能多的函数上)是否存在(可能的,未来的)缺点?
更具体地说:将extern "C"添加到只使用C功能的函数中有什么缺点吗?换句话说,那些不使用@k-5中列出的功能的函数有什么缺点?
发布于 2017-09-08 12:47:51
缺点是,您只能在extern "C"函数的接口中使用C函数也可用的特性。
这意味着:
1. you can't use default values for function arguments,
2. you can't use reference arguments,
3. you can't pass C++ classes by value (including smart pointers),
4. you can't pass `enum class` arguments,
5. you can't pass `bool` without converting it to `int`,
6. you can't overload such functions, and probably more that I can't recall at the moment.https://stackoverflow.com/questions/46116836
复制相似问题