我試圖在用Swift編寫的Xcode項目中使用LLVM C API。爲此,我鬆散地按照指南here,但有麻煩。在編譯步驟,加入了包括路徑在Xcode構建設置後,我收到以下錯誤:在Swift Xcode項目中使用LLVM C API
<unknown>:0: error: module 'LLVM_Backend.CodeGen.PBQP.math' requires feature 'cplusplus'
/Users/freddy/Development/llvm-source/build/include/llvm/Support/DataTypes.h:35:10: note: submodule of top-level module 'LLVM_Backend' implicitly imported here
#include <math.h>
^
<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "./Analysis.h"
^
/Users/freddy/Development/llvm-source/llvm/include/llvm-c/./Analysis.h:22:10: note: in file included from /Users/freddy/Development/llvm-source/llvm/include/llvm-c/./Analysis.h:22:
#include "llvm-c/Types.h"
^
/Users/freddy/Development/llvm-source/llvm/include/llvm-c/Types.h:17:10: error: could not build module 'LLVM_Support_DataTypes'
#include "llvm/Support/DataTypes.h"
^
/Users/freddy/Development/Xcode Projects/SwiftLLVMTest/SwiftLLVMTest/main.swift:10:8: error: could not build Objective-C module 'LLVM_C'
import LLVM_C
在幻燈片中的下一個步驟是添加的標誌:
-Xcc -D__STDC_CONSTANT_MACROS \
-Xcc -D__STDC_LIMIT_MACROS
但我不確定將它們放置在構建設置中的位置 - 將它們添加到「其他C標誌」或「其他Swift標誌」選項似乎沒有任何作用。
我應該怎麼做呢?
嗨@Jumhyn,很難看到你已經做了什麼以及它失敗了,所以我建議你看看這些文章:https://lowlevelbits.org/how-to-use -llvm-api-with-swift /,https://medium.com/compileswift/how-to-setup-xcode-swift-project-to-use-llvm-c-apis-3ccbf081d002 – AlexDenisov