c调用c++函数
时间:2019-05-29 23:03:43
收藏:0
阅读:102
#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
原文:https://www.cnblogs.com/dianrain/p/10946514.html
评论(0)