如何在Windows上使用clang atomics库?

时间:2017-02-27 13:57:18

标签: windows clang llvm-clang

我有一个程序,其简化版本如下:

struct T {
    char data[17]; // Really, anything larger than 16 bytes
};

int main() {
    _Atomic(struct T) atomic;

    atomic = (struct T) {};

    return 0;
}

如果我尝试在Windows上编译此程序,那么我会收到此错误:

C:> clang test.c
test-95dcb2.o : error LNK2019: unresolved external symbol __atomic_store referenced in function main
a.exe : fatal error LNK1120: 1 unresolved externals
clang.exe: error: linker command failed with exit code 1120 (use -v to see invocation)

在clang文档中,如果-latomic无法编译为机器指令,则表示需要使用_Atomic链接器标记,如本例所示。但是,该标志在Windows上不起作用:

test-95dcb2.o : error LNK2019: unresolved external symbol __atomic_store referenced in function main
a.exe : fatal error LNK1120: 1 unresolved externals
clang.exe: error: linker command failed with exit code 1120 (use -v to see invocation)

我使用的是Clang 3.9.1。有没有办法使这项工作,或者它在Windows上不受支持?

0 个答案:

没有答案