23

I'd like to make use of the new atomic operations provided by the C11 standard. However, trying to #include the appropriate header file gives me this:

 csort-par.c:5:23: fatal error: stdatomic.h: No such file or directory
 #include <stdatomic.h>

The documentation at http://gcc.gnu.org/wiki/C11Status seems to say that the header file has been provided since GCC 4.7... am I missing something? __STDC_NO_ATOMICS__ is not defined.

gcc --version is as follows:

gcc (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
Copyright (C) 2013 Free Software Foundation, Inc.

And I confirmed that __STDC_NO_ATOMICS__ was not defined as follows:

#ifdef __STDC_NO_ATOMICS__
#error yes
#else
#error no
#endif

yields:

csort-par.c:10:2: error: #error no
 #error no

EDIT: Thanks for the swift replies.

In case anyone stumbles on this from Google with the same question, here's a fix in the interim until they release GCC 4.9:

UNIX Portable Atomic Operations

Community
  • 1
  • 1
Patrick Collins
  • 10,306
  • 5
  • 30
  • 69

1 Answers1

27

This file is missing. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58016

It was fixed only in gcc 4.9, as its release notes says (http://gcc.gnu.org/gcc-4.9/changes.html)

keltar
  • 17,711
  • 2
  • 37
  • 42
  • Yes exactly, I checked that :) – Jekyll Dec 02 '13 at 11:25
  • @Jekyll thanks, don't have 4.9 at work so was unable to verify, but've red it in release notes about a week ago. Although i doubt mere copying file from 4.9 to previous versions will work - as it makes heavy use of `_Atomic`, which looks unavailable on previous versions. – keltar Dec 02 '13 at 11:30
  • I don't have 4.9 as well but I could verify (see answer below) that previous versions only give support for c++ std::atomic extension. I searched on my path and I verified that being true. Moreover seems to be documented,infact the bug there was rejected basically telling that an "incomplete documented feature" cannot be reported as a bug. – Jekyll Dec 02 '13 at 11:32