首页 > 编程语言 > 详细

c调用c++函数

时间:2019-05-29 23:03:43      阅读:101      评论:0      收藏:0      [点我收藏+]
#ifndef CPPFUNCTIONS_H_
#define CPPFUNCTIONS_H_
#ifdef __cplusplus
int cpp_func(int input);
extern "C" {
#endif
int c_func(int input);
#ifdef __cplusplus
}
#endif
#endif /* CPPFUNCTIONS_H_ */
#include "CppFunctions.h"
int cpp_func(int input) {
 return 5;
}
int c_func(int input) {
 return cpp_func(input);
}
#include <stdio.h>
#include "CppFunctions.h"
int main(int argc, char **argv) {
 printf("%d\n", c_func(10));
 return 0;
}

转载,已验证OK

c调用c++函数

原文:https://www.cnblogs.com/dianrain/p/10946514.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!