compile error: <atomic> is not implemented

Solution 1:

Looking at the question, the edits and the comments, it's becoming clear that the setup of your compiler chain and the headers is probably the cause. You could keep trying to add things, but I would take a different tack:

  1. Make a full backup of the Mac - one that you are serious about using if you wipe the machine and run a test compile of the program and then restore either the full backup or files you need selectively from the backup.
  2. Remove Xcode and remove all the compilers you have downloaded and installed.
  3. Install a tool to assist with the maintenance and installation of the compiler and the need header library files for the latest c++ standard.

The tool I use is homebrew, so you can install it per https://brew.sh

  1. brew update
  2. brew doctor - and be sure you follow any of the advice in the doctor or post here for advice
  3. brew install gcc

Here is the test program I used for a "minimal test case"

#include<atomic>
#include<iostream>

using namespace std;

int main()
{
    cout << "Hello World" << endl;
}

Before using the "brew" version of gcc, I get what I presume is the same error as you:

mac:Desktop me$ /usr/bin/gcc gate\ test.cpp
In file included from gate test.cpp:1:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/atomic:543:2: error: <atomic> is not implemented
#error <atomic> is not implemented
 ^
1 error generated.
mac:Desktop me$ which gcc
/usr/bin/gcc

But if I compile it using the "brew installed gcc", I'm getting a very nice detailed message

mac:Desktop me$ g++-5 gate\ test.cpp 
In file included from /usr/local/Cellar/gcc/5.2.0/include/c++/5.2.0/atomic:38:0,
                 from gate test.cpp:1:
/usr/local/Cellar/gcc/5.2.0/include/c++/5.2.0/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support for the \
  ^
mac:Desktop me$ g++-5 gate\ test.cpp -std=c++11

TLDR;

  1. pointing your compiler to g++5
  2. delete other compilers as needed (including Xcode possibly)
  3. adding the compile option -std=c++11

Solution 2:

Had the same issue with xCode 6.4. When using atomic in a simple helloWorld program it worked, but when using a project generated by CMake, I had the "#error is not implemented"

It appears CMake needs special flags to enable c++11 on mac... So, did exactly (almost... replaced if(UNIX) by if(APPLE)) as kitware indicates here:

https://cmake.org/Wiki/CMake/Tutorials/C%2B%2B11Flags

In case the link stops working one day....

cmake_minimum_required(VERSION 2.6)

PROJECT(Test)

if(UNIX)
    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=gnu++0x")
endif()

# MSVC does not require any special flags