2012-10-04 78 views
1

我有以下的頭文件: gaiageo.h 其定義爲如何創建接口文件痛飲

#ifndef DOXYGEN_SHOULD_SKIP_THIS 
/* stdio.h included for FILE objects. */ 
#include <stdio.h> 
#ifdef DLL_EXPORT 
#define GAIAGEO_DECLARE __declspec(dllexport) 
#else 
#define GAIAGEO_DECLARE extern 
#endif 
#endif 

#ifndef _GAIAGEO_H 
#ifndef DOXYGEN_SHOULD_SKIP_THIS 
#define _GAIAGEO_H 
#endif 

#include "gg_const.h" 
#include "gg_structs.h" 
#include "gg_core.h" 
#include "gg_mbr.h" 
#include "gg_formats.h" 
#include "gg_dynamic.h" 
#include "gg_advanced.h" 

#endif /* _GAIAGEO_H */ 

所包含的頭文件與GAIAGEO_DECLARE上佈滿,爲 例如gg_formats.h(其很典型的包括頭)有以下幾點:

/** 
\file gg_formats.h 

Geometry handling functions: formats 
*/ 

#ifndef _GG_FORMATS_H 
#ifndef DOXYGEN_SHOULD_SKIP_THIS 
#define _GG_FORMATS_H 
#endif 

#ifdef __cplusplus 
extern "C" 
{ 
#endif 

/* function prototypes */ 

/** 
Test CPU endianness 

\return 0 if big-endian: any other value if little-endian 
*/ 
    GAIAGEO_DECLARE int gaiaEndianArch (void); 

/** 
Import an INT-16 value in endian-aware fashion 

\param p endian-dependent representation (input buffer). 
\param little_endian 0 if the input buffer is big-endian: any other value 
for little-endian. 
\param little_endian_arch the value returned by gaiaEndianArch() 

\return the internal SHORT value 

\sa gaiaEndianArch, gaiaExport16 

\note you are expected to pass an input buffer corresponding to an 
allocation size of (at least) 2 bytes. 
*/ 
    GAIAGEO_DECLARE short gaiaImport16 (const unsigned char *p, 
        int little_endian, 
        int little_endian_arch); 
#ifdef __cplusplus 
} 
#endif 

#endif /* _GG_FORMATS_H */ 

這是我在創建接口文件,並希望一些幫助的第一次嘗試,在線文檔是混淆了我嗎?

我應該爲每個頭創建一個接口文件,我應該如何創建包含gaiageo.h的接口?

回答

3

這應該讓你開始,但很難確切知道你需要什麼。

%include <windows.i>使SWIG處理窗口主義像__declspec(dllexport)

默認情況下,SWIG不會遞歸包含文件,因此包括SWIG需要處理的文件。有一個開關來緩存,但它會處理stdio.h

%module gaiageo 

%{ 
#include "gaiageo.h" 
%} 

%include <windows.i> 
%include "gaiageo.h" 
%include "gg_const.h" 
%include "gg_structs.h" 
%include "gg_core.h" 
%include "gg_mbr.h" 
%include "gg_formats.h" 
%include "gg_dynamic.h" 
%include "gg_advanced.h" 

保存,作爲一個gaiageo.i文件並運行是這樣的:

swig -c++ -<target_language> gaiageo.i