C++中如何调用C里面的函数

来源:互联网 发布:企业邮箱破解软件 编辑:程序博客网 时间:2024/04/29 21:38

经验证:下机制可行

Here is a setup that allows C++ to call C.
Maybe this method is appropriate for your need :

1) use the "not using precompiled headers" option

2) sample C header file (cheader.h)




#ifdef __cplusplus
extern "C" {
#endif
//
//
void cfun();
//
//
#ifdef __cplusplus
}
#endif





3) sample C file (myc.c)


#include "cheader.h"
//
void cfun()
{


}





4) in the CPP file where you want to call C function :


#include "cheader.h"
//
//
//
//
cfun();

原创粉丝点击