title: C++ "'__gthread_active_p' was not declared in this scope"
body: <p>I'm getting GCC compiling on windows with std::atomic and std::thread support.
  I'm using mingw from here: <a href="http://winlibs.com/" rel="nofollow noreferrer">http://winlibs.com/</a></p>
  <p>I'm building with this command:</p>
  <pre><code>g++.exe @CMakeFiles/StrFormatsJSONTest.dir/includes_CXX.rsp -latomic -lglu32 -lopengl32 -D_WIN32_WINNT=0x600 -DWINVER=0x600 -D_WIN32_LEAN_AND_MEAN=1 -g -std=gnu++2a -o main.cpp.obj -c main.cpp
  </code></pre>
  <p>However, when using <code>#include &lt;atomic&gt;</code> the following error occurs:</p>
  <pre><code>[build] c:\utils\bin\mingw32\include\c++\10.3.0\ext\atomicity.h:83:9: error: '__gthread_active_p' was not declared in this scope
  [build]    83 |     if (__gthread_active_p())
  </code></pre>
  <p>If I define the function manually, I get a multiple definition error (so clearly it in the project somehow).</p>
  <p>I'm including threads using:</p>
  <pre><code>    find_package( Threads )
      target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_THREAD_LIBS_INIT} )
  </code></pre>
  <p>I'm including <code>latomic</code> using:</p>
  <pre><code>    set(CMAKE_C_FLAGS &quot;${CMAKE_C_FLAGS} -latomic -lglu32 -lopengl32 -D_WIN32_WINNT=0x600 -DWINVER=0x600 -D_WIN32_LEAN_AND_MEAN=1 -D__GTHREADS=1&quot;)
  </code></pre>
  <p>^ Like this because I need it in ALL targets within the project.</p>
  <p>The library states that the function should be present if GTHREADS macro is 1:</p>
  <p><a href="https://i.stack.imgur.com/weigM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/weigM.png" alt="enter image description here" /></a></p>
  <p>Clearly it is, thats where the error is:</p>
  <p><a href="https://i.stack.imgur.com/9doAd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9doAd.png" alt="enter image description here" /></a></p>
  <p>When I add a definition (weakly linked) before <code>#include &lt;atomic&gt;</code> it works... But I get other errors such as:</p>
  <pre><code>error: '__gthread_once_t' does not name a type; did you mean '__gthread_active_p'?
  </code></pre>
  <p>For some reason GCC isn't including any one of these:</p>
  <ol>
  <li>gthr-default.h</li>
  <li>gthr-posix.h</li>
  <li>gthr-single.h</li>
  </ol>