c++里面用c语言的标准库的时候, 包含的c的标准头文件是不是自动extern "C"了.
比如 :
#include <string.h>
#include <stdio.h>
是不是自动处理过了,可以用c的编译链接约定去找到并链接c标准库的函数?
伊谢尔伦2017-04-17 13:20:01
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
伊谢尔伦2017-04-17 13:20:01
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
ringa_lee2017-04-17 13:20:01
Don’t worry about this, C++ is compatible with most C. As for linking dynamic libraries, the compiler has already done it for you