2010-11-10 45 views
0

之前期望'=',',',';','asm'或'attribute'我試圖使用在iOS中用c編寫的靜態庫項目。我將.lib文件和.h文件包含在iOS項目中。當我嘗試在我的一個Objective-C類中導入頭文件時,我的靜態庫的.h文件中出現很多Expected '=',',',';','asm' or 'attribute' before...錯誤。在iOS項目中使用靜態.lib(c)

我正在使用xCode4 for Development,它似乎正確添加了庫。當我使用Xcode 3打開項目時,這些庫將被添加到目標組「帶庫的鏈接二進制文件」,如How to resolve linking error - static lib iPhone中所述。

我從一家實際使用這些庫的公司獲得了靜態庫,所以我猜頭文件沒有錯。我自己找不到任何錯誤。

有沒有辦法在ios項目中使用正確的頭文件的.lib文件?或者除了將lib文件添加到目標組以外,還必須執行任何操作以便在我的項目中使用它們?

此致 麥克

編輯

實際錯誤消息:

預期* *前 預期 '=', '', ';', 'ASM'或「屬性」之前_far _pascal

標題導入的實際代碼:

#import <Foundation/Foundation.h> 
#import "SomethingDll.h" 


@interface AccountingEntry : NSObject { 
    NSString *entryDescription; 
    NSDate *entryDate; 
    double entryAmount; 
    NSString *entryType; 

} 

@property (nonatomic, retain) NSString *entryDescription; 
@property (nonatomic, retain) NSDate *entryDate; 
@property (nonatomic) double entryAmount; 
@property (nonatomic, retain) NSString *entryType; 

//class methods go here 

//instance methods go here 
-(id)initWithDescription:(NSString *)eDesc date:(NSDate*)eDate amount:(double)eAmount type:(NSString *)eType; 


@end 

lib的.h文件。

#ifndef __SOMETHING_DLL 
#define __SOMETHING_DLL 



// constants for a function 

#define FIRST_ERRTEXT 0 
#define NEXT_ERRTEXT 1   

/* 
... 
some other #define of constants 

*/ 

// Callback-Pointer Definitionen 

#define INFO_FUNC_DECL   BOOL (CALLBACK *lpInfoFunc)(int) 
#define FILETRANS_FUNC_DECL  void (CALLBACK *lpFileTransFunc)(int,long) 


// Funktionsdeklarationen 

#ifdef WIN32 
#define IMPORTAPI WINAPI 
#else 
#define IMPORTAPI _far _pascal 
#endif 


#ifdef __cplusplus 
extern "C" { 
#endif 

    void IMPORTAPI Something_Config(  int iLogLevel,     char *szLogFile,  
           long lTimeOut_Connect,   long lTimeOut, 
           long lTimeout_GetFile,   long lTime_Info, 
           int iSSLVersion,    char *szSSLCipher, 
           char *szVerifyCertificateFile, char *szVerifyCertificatePath); 
/* 
    ... 
    a lot of other functions 
    ... 
*/ 
#ifdef __cplusplus 
} 
#endif      

#endif // End 
+0

某些實際的錯誤消息可能會使診斷問題變得更加容易。 – 2010-11-10 10:57:08

+0

或者其他導入頭文件的實際代碼 – Eimantas 2010-11-10 11:02:00

+0

我添加了lib的實際代碼,錯誤消息和.h文件。謝謝。 – 2010-11-10 11:23:35

回答

1

它接縫,這lib是Win32中,_far _pascal指令不適用於GCC和其他錯誤可能來自失蹤的定義。 也許你必須尋找另一個lib才能完成這項工作。

+0

這是否意味着整個庫在IOS上不可用?我不太熟悉c。 __far _pascal在做什麼? – 2010-11-10 12:09:05

+0

這是接縫...... iOS有很多lib,當然你可以找到一個來完成這項工作。 '_far _pascal'=「_far _pascal」修飾符使用正常的DLL參數傳遞約定,該約定指定DLL位於單獨的段(「_far」)中,並使用「_pascal」參數傳遞系統,即參數爲從左向右傳遞,被調用的函數清理堆棧「(http://www.ubercode.com/learning-to-write-programs-in-c.html) – 2010-11-10 12:21:59

+0

好的。非常感謝你。 – 2010-11-10 12:41:46

相關問題