2013-08-24 6 views
1

(링커 오류)호출 C 함수 I은 C 함수 작성한

헤더

//FileSystem.h file 
#import <Foundation/Foundation.h> 
BOOL AddSkipBackupAttributeToItemAtURL(NSURL *url); 

구현

//FileSystem.mm 
#import "FileSystem.h" 
#import <sys/xattr.h> 
#import <Support/Support.h> 

static const char* attrName = "com.apple.MobileBackup"; 
BOOL AddSkipBackupAttributeToItemAtURL(NSURL *url) { 
    BOOL operationResult = NO; 
    // some implementation 
    return operationResult; 
} 

나 다른 부분에서 AddSkipBackupAttributeToItemAtURL 호출있어 모든 응용 프로그램의 블록을 함수를 호출하는 한 곳을 제외한 모든 확인을 것입니다. 그런 일이 왜 이해가 안

Undefined symbols for architecture i386:
"AddSkipBackupAttributeToItemAtURL", referenced from: __36-[UpdateFileAsyncOperation start]_block_invoke in UpdateFileAsyncOperation.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

,이 블록에 따라 방법 : 그 장소에서

__block UpdateFileAsyncOperation* selfOperation = self; 
    _contentDownloader.completionBlock = ^(NSData* data) { 
     [data saveForcedToPath:selfOperation.filePath]; 
     NSURL* fileUrlWithScheme = [NSURL fileURLWithPath:selfOperation.filePath]; 
     AddSkipBackupAttributeToItemAtURL(fileUrlWithScheme); 
     [runLoop removePort:port forMode:NSDefaultRunLoopMode]; 
     [selfOperation completeOperation]; 
    }; 

진행 연결하는 동안 오류가? 어떻게 해결할 수 있습니까? 감사합니다.

업데이트 : 블록에 종속적이지 않습니다. 클래스의 다른 위치로 함수를 호출했습니다. 오류가 여전히 있습니다. 이유를 찾고 있습니다.

+0

가능한 중복 [어떤 이름 맹 글링이며, 작동합니까 어떻게?] (http://stackoverflow.com/questions/1314743/ 파일 퍼트있다 무엇 - 이름 - mangling - and-how-does-it-work) –

답변

7

문제를 해결했습니다. 블록에 종속되지 않습니다. 파일 확장명에 따라 다릅니다.

문제 파일의 확장자는 ".m"이고 다른 파일의 확장자는 ".mm"입니다.

그래서 나는 FileSystem.h에서 다음 매크로의

#ifdef __cplusplus 
extern "C" { 
#endif 

BOOL AddSkipBackupAttributeToItemAtURL(NSURL *url); 

#ifdef __cplusplus 
} 
#endif