Compilation error with Mojave: error: ‘_Atomic’ does not name a type After updating to Mojave 10.14.4 and Xcode 10.2, I fail to compile GCC 8.3.0. The error message is

In file included from /usr/include/sys/sysctl.h:83,
                 from ../../gcc-8.3.0/gcc/config/darwin-driver.c:30:
/usr/include/sys/ucred.h:94:2: error: ‘_Atomic’ does not name a type
  _Atomic u_long          cr_ref;  /* reference count */
  ^~~~~~~


I have not found any clue how this can be fixed. The header in question is

struct ucred {
    LIST_ENTRY(ucred)       cr_link; /* never modify this without KAUTH_CRED_HASH_LOCK */
#if defined(__STDC_VERSION__) &amp;&amp; __STDC_VERSION__ &gt;= 201112L &amp;&amp; !defined(__STDC_NO_ATOMICS__)
    _Atomic u_long          cr_ref;  /* reference count */
#elif defined(__cplusplus) &amp;&amp; __cplusplus &gt;= 201103L
    _Atomic u_long          cr_ref;  /* reference count */   // &lt;--- this line
#else
    volatile u_long         cr_ref;  /* reference count */
#endif


Any ideas are highly appreciated!
I encountered the same problem myself. The error is actually reported by g++, a C++ compiler. On MacOS 10.14.4, the header file &lt;sys/ucred.h&gt; uses the _Atomic keyword for C++, although it is only defined in the C standard. (I assume that Apple's compiler clang++ defines this keyword as extension to the C++ standard.)

The proper fix is to tell gcc to "fixinclude" the header file &lt;sys/ucred.h&gt;. This patch does this. This is a patch that needs to be applied to the source code of GCC 8.3.0 before building it.