title: Interoperabilty between C and C++ atomics
body: <p>Suppose, I have a task that might be cancelled from another thread. The task is performed in a C function, another thread runs C++ code. How do I do that?</p>
  
  <p>Rough example.</p>
  
  <p>C:</p>
  
  <pre><code>void do_task(atomic_bool const *cancelled);
  </code></pre>
  
  <p>C++:</p>
  
  <pre><code>std::atomic_bool cancelled;
  …
  do_task(&amp;cancelled);
  </code></pre>
  
  <p>For now, I created a file <code>atomics.h</code> with the following content:</p>
  
  <pre><code>#ifdef __cplusplus
  #include &lt;atomic&gt;
  using std::atomic_bool;
  #else
  #include &lt;stdatomic.h&gt;
  #endif
  </code></pre>
  
  <p>It appears to work, but I don't see any guarantees for that. I wonder, if there is a better (correct) way.</p>