我想使用那些用C寫的一些功能,但是我收到以下錯誤消息時:重複的符號錯誤鏈接C代碼
duplicate symbol _getInt in:
/Users/<redacted>/Library/Developer/Xcode/DerivedData/Test-ecbrpcljzanjildnvawnrcgejdwn/Build/Intermediates/Test.build/Debug-iphonesimulator/Test.build/Objects-normal/x86_64/source.o
/Users/<redacted>/Library/Developer/Xcode/DerivedData/Test-ecbrpcljzanjildnvawnrcgejdwn/Build/Intermediates/Test.build/Debug-iphonesimulator/Test.build/Objects-normal/x86_64/swift.o
ld: 1 duplicate symbol for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
swift.swift:
print(getInt())
header.h:
#ifndef header_h_
#define header_h_
#include "source.c"
#endif
由source.c:
int getInt() {
return 4;
}
爲什麼在.h文件中包含.c文件? – rmaddy