title: std::atomic with custom class (C++ 11)
body: <p>I am using std::atomic with a custom class in my library. All works fine with MSVC, but now that i'm trying to get it to run on macOS, i get a linker error:</p>
  
  <p>undefined symbols for architecture x86_64:
  "__atomic_store", referenced from:
  _main in main.o</p>
  
  <p>I've created some test code to replicate this</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;atomic&gt;
  
  using namespace std;
  
  class Vec {
      public:
      int x, y, z;
      Vec() { x = y = z = 0; }
  };
  
  std::atomic&lt;Vec&gt; x;
  
  
  int main()
  {
    Vec a;
    x = a;
    cin.get();
      return 0;
  }
  </code></pre>
  
  <p>Of course this example doesn't make much sense, but it's the shortest I could come up with. It does run in VS2012, but not in xcode (giving me the linker error shown above).</p>
  
  <p>So what's going on? Am I abusing std::atomic here? The library I'm working on is heavily multithreaded and used for audio processing. So if I'm not using std::atomic in the correct way, it is not really showing, because performance is very good and I don't have any threading problems with it. Or is xcode perhaps lacking something?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>I've checked andrey's answer because it has the most information, although all 3 answers are useful. I'm no expert in this (obviously) but it seems that VS2012 goes beyond what should be implemented in C++11.</p>
  
  <p>So how to go from here? I see a few options.</p>
  
  <ol>
  <li>Don't use atomic for this class. In my particular case this would be very hard because my vector class is used all over the code. Locking and unlocking mutexes would probably slow things down a lot.</li>
  <li>Implement the functions myself for atomic. That looks very complicated to me. I'll save it as the last option.</li>
  <li>See if something can be done with boost::atomic. This seems to work at first glance. I have to do more tests on it though.</li>
  </ol>