search
尋找貓咪~QQ 地點 桃園市桃園區 Taoyuan , Taoyuan

LINUX C/C++ C++中是如何使用C開發的API(o/a/so/dll) – jashliao部落格

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 提供 原文連結

寵物協尋 相信 終究能找到回家的路
寫了7763篇文章,獲得2次喜歡
留言回覆
回覆
精彩推薦