3C科技 娛樂遊戲 美食旅遊 時尚美妝 親子育兒 生活休閒 金融理財 健康運動 寰宇綜合

Zi 字媒體

2017-07-25T20:27:27+00:00
加入好友
LINUX C/C++ C++中是如何使用C開發的API(o/a/so/dll) 資料來源: https://mp.weixin.qq.com/s/NNJyZtQaLkbGSbhLkDZZIg test.c #include"test.h" void testCfun() { printf("I am c fun\n"); return; } test.h #include extern "C"{ void testCfun(); } main.cpp #include"test.h" #include using namespace std; int main(void) { /*调用C接口*/ cout< 編譯: $ gcc -c test.c $ g++ -o main main.cpp test.o $ ./main start to call c function I am c fun end to call c function ——- test.h #include #ifdef __cplusplus extern "C"{ #endif void testCfun(); #ifdef __cplusplus } #endif main.c #include"test.h" int main(void) { /*调用C接口*/ testCfun(); return 0; }

本文由jashliaoeuwordpress提供 原文連結

寫了 5860316篇文章,獲得 23313次喜歡
精彩推薦