[PATCH] score: Workaround for GCC 4.9

Sebastian Huber sebastian.huber at embedded-brains.de
Wed May 7 12:58:41 UTC 2014


The GCC 4.9 ships its own <stdatomic.h> which is not C++ compatible.
The suggested solution was to include <atomic> in case C++ is used.
This works at least with GCC 4.9.  See also:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932

An alternative to these C pre-processor stuff is to use Autoconf magic.
---
 cpukit/score/include/rtems/score/cpustdatomic.h |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h
index a663a06..99cf524 100644
--- a/cpukit/score/include/rtems/score/cpustdatomic.h
+++ b/cpukit/score/include/rtems/score/cpustdatomic.h
@@ -18,7 +18,13 @@
 #ifndef _RTEMS_SCORE_GENERAL_STDATOMIC_CPU_H_
 #define _RTEMS_SCORE_GENERAL_STDATOMIC_CPU_H_
 
-#include <stdatomic.h>
+#if defined(__cplusplus) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 9
+  #include <atomic>
+  using namespace std;
+#else
+  #include <stdatomic.h>
+#endif
+
 #include <stdbool.h>
 #include <stdint.h>
 
-- 
1.7.7




More information about the devel mailing list