Symbian中IMPORT C關鍵字釋義

2021-04-14 09:17:00 字數 1485 閱讀 4570

在symbian程式中我們經常會看到import_c這個關鍵字,它是c:/symbian/8.0a/s60_2nd_fp2_sc/epoc32/include下e32def.h檔案裡面定義的乙個巨集. 

原定義如下:

#define import_c __declspec(dllexport)

那麼__declspec(dllexport)又是什麼東東呢?

先看**:

以下是在dev-c++裡建立自已的dll時的dll.h裡面的**,這裡面有乙個_declspec(dllexport)

#ifndef _dll_h_

#define _dll_h_     //防重複定義

#if building_dll

# define dllimport __declspec (dllexport)

#else /* not building_dll */

# define dllimport __declspec (dllimport)

#endif /* not building_dll */

dllimport void helloworld (void);

#endif /* _dll_h_ */

上面**裡面的_delcspce(dllexport)被定義為巨集,這樣可以提高程式的可讀性!這個的作用是將函式定義為匯出函式,也就是說這個函式要被包含這個函式的程式之外的程式呼叫!本語句中就是:void helloword(void)

摘自msdn:在 32 位編譯器版本中,可以使用 __declspec(dllexport) 關鍵字從 dll 匯出資料、函式、類或類成員函式。__declspec(dllexport)將匯出指令新增到物件檔案

若要匯出函式,__declspec(dllexport)關鍵字必須出現在呼叫約定關鍵字的左邊(如果指定了關鍵字)。例如:

__declspec(dllexport) void __cdecl function1(void);
若要匯出類中的所有公共資料成員和成員函式,關鍵字必須出現在類名的左邊,如下所示:

class __declspec(dllexport) cexampleexport : public cobject;
生成 dll 時,通常建立乙個包含正在匯出的函式原型和/或類的標頭檔案,並將__declspec(dllexport)新增到頭檔案中的宣告。若要提高**的可讀性,請為__declspec(dllexport)定義乙個巨集並對正在匯出的每個符號使用該巨集:

#define dllexport   __declspec( dllexport )
__declspec(dllexport)將函式名儲存在 dll 的匯出表中。

Symbian中IMPORT C關鍵字釋義

1.串轉換成數字 tbuf16 20 buf l 123 tlex lex buf tint inum lex.val inum 2.數字轉換成串 tbuf16 20 buf tint inum 20 buf.format l d inum 3.將symbian串轉換成char串 char p nu...

symbian資料symbian資料

symbian資料symbian資料 更多資料在 url http study url url http 部落格 url http 已上傳的檔案 active object技術講解 pdf課件.rar 635 kb 備註 提交 刪除 symbian c 開發入門之概述 pdf課件.rar 670.8...

Symbian中同步socket用法

symbian中同步socket用法 下邊的 是介紹同步socket的用法 需要用到的lib,可能不全,請看sdk的help自己新增 esock.lib 需要的標頭檔案,可能不全,請看sdk的help自己新增 include include include if defined wins lit k...