inを使用しようとしてstd::atomic<>
いますが、私のテスト ケースは Clang と GCC の両方でリンカー エラーで失敗します。何故ですか?基本的でないタイプも含め、すべてのタイプがサポートされていました。struct sigaction
std::vector
#include <atomic>
#include <vector>
#include <signal.h>
std::vector<std::atomic<struct sigaction> > vec (1);
int main() {
struct sigaction sa = { };
vec[0].store (sa);
sa = vec[0].load ();
return 0;
}
http://coliru.stacked-crooked.com/a/df4cfcbe48ecc992を参照してください。結果は
g++ -std=c++11 -O2 -Wall -pedantic -pthread main.cpp && ./a.out ; g++ -v 2>&1 |grep 'gcc version'
clang++ -std=c++11 -O2 -Wall -pedantic -pthread main.cpp && ./a.out ; clang++ -v 2>&1 |grep 'clang version'
/tmp/ccgNkprP.o: In function `main':
main.cpp:(.text.startup+0x41): undefined reference to `__atomic_store'
main.cpp:(.text.startup+0x5f): undefined reference to `__atomic_load'
collect2: error: ld returned 1 exit status
gcc version 5.2.0 (GCC)
/tmp/main-c75098.o: In function `main':
main.cpp:(.text+0x96): undefined reference to `__atomic_store'
main.cpp:(.text+0xb1): undefined reference to `__atomic_load'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
clang version 3.6.0 (tags/RELEASE_360/final 235480)