C++调用C中的函数
extern_in_c.c 函数如下
#include <stdio.h>
int he()
{
printf("hjz in c\n");
return 0;
}
extern_in_c.h 内容如下:
#ifndef EXTERN_IN_C_H
#define EXTERN_IN_C_H
extern "C"
{
int he(void);
}
#endif
c_plus_plus_call_c.cpp 内容如下:
#include <stdio.h>
extern "C"
{
#include "extern_in_c.h"
}
int main()
{
he();
return 0;
}