0

I am trying to use static libraries that are written in c in an iOS Project. I included the .lib files and the .h into the iOS project. When I try to import the header files in one of my objective-C classes I get a lot of Expected '=',',',';','asm' or 'attribute' before... errors in the .h file of my static library.

I am using xCode4 for Development which seems to have added the libs correctly. When I open the project with Xcode 3 the libs are added to the Target Group "link binary with libraries" as stated in How to resolve linking error - static lib iPhone.

I got the static libs from a company that actually uses these libraries so I guess the header file is not at fault. I could not find any errors myself.

Is there a way to use .lib files with correct header files in an ios project? Or do I have to do anything besides adding the lib files to the target group in order to use them in my project?

Best Regards, Mike

edit

the actual error message:

Expected * before * Expected '=',',',';','asm' or 'attribute' before _far _pascal

The actual code where the header is imported:

#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

The .h file of the lib.

#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
Community
  • 1
  • 1
Michael Klein
  • 785
  • 6
  • 14

1 Answers1

1

It seams that this lib is for Win32, the _far _pascal directive is not available on gcc and the other errors may come from missing definitions. Maybe you have to look for another lib to do the job.

Bruno Berisso
  • 1,091
  • 11
  • 33
  • does this mean that the whole library is unusable on IOS? I am not really familiar with c. what does __far _pascal do? – Michael Klein Nov 10 '10 at 12:09
  • It's seams to... There is a lot of lib's for iOS, surely you can find one to do the job. '_far _pascal' = "The "_far _pascal" modifiers use the normal DLL parameter passing convention, which specifies DLLs are in a separate segment ("_far") and that the "_pascal" parameter passing system is used, which is that parameters are passed left to right and that the called function cleans up the stack" (http://www.ubercode.com/learning-to-write-programs-in-c.html) – Bruno Berisso Nov 10 '10 at 12:21