c++ c混合编程问题?
高洛峰
高洛峰 2017-04-17 13:18:01
0
3
716

c++里面用c语言的标准库的时候, 包含的c的标准头文件是不是自动extern "C"了.

比如 :

 #include <string.h>
 #include <stdio.h>
 
 是不是自动处理过了,可以用c的编译链接约定去找到并链接c标准库的函数?
高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(3)
伊谢尔伦

Yes, you can check the header file yourself and it is easy to find the following code

#ifdef __cplusplus
extern "C" {
#endif
...
...
#ifdef __cplusplus
}
#endif
伊谢尔伦

If it is a c standard library, it is best to import it like this:

#include <cstring>
#include <cstdio>

This will help you deal with some problems such as function polymorphism

左手右手慢动作

Don’t worry about this, C++ is compatible with most C. As for linking dynamic libraries, the compiler has already done it for you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template