This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch releases/12.12
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/releases/12.12 by this push:
new b05b5eb9d1f include/nuttx/atomic.h: fix C++ definition conflicts
b05b5eb9d1f is described below
commit b05b5eb9d1f308e1dc82c5f96613e518889f6b56
Author: raiden00pl <[email protected]>
AuthorDate: Sat Oct 18 11:12:13 2025 +0200
include/nuttx/atomic.h: fix C++ definition conflicts
when C++ lib has an atomic implementation, we shouldn't include NuttX
defined macros to avoid conflicts
Fix errors like:
build/include/libcxx/__atomic/atomic.h:445:1: error: expected identifier
before numeric constant
445 | atomic_fetch_add(volatile atomic<_Tp>* __o, typename
atomic<_Tp>::difference_type __op) _NOEXCEPT
| ^~~~~~~~~~~~~~~~
Signed-off-by: raiden00pl <[email protected]>
---
include/nuttx/atomic.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/nuttx/atomic.h b/include/nuttx/atomic.h
index 79d475f0189..2a6ff228a12 100644
--- a/include/nuttx/atomic.h
+++ b/include/nuttx/atomic.h
@@ -29,6 +29,13 @@
#include <stdbool.h>
+#define NEED_ATOMIC_MACROS
+#if defined(__has_include)
+# if __has_include(<atomic>) && defined(__cplusplus)
+# undef NEED_ATOMIC_MACROS
+# endif
+#endif
+
#if defined(__has_include) && !defined(CONFIG_LIBC_ARCH_ATOMIC)
# if __has_include(<atomic>) && defined(__cplusplus)
extern "C++"
@@ -98,6 +105,8 @@ typedef volatile int64_t atomic64_t;
* Pre-processor Definitions
****************************************************************************/
+#ifdef NEED_ATOMIC_MACROS
+
#define atomic_set(obj, val) ATOMIC_FUNC(store, 4)(obj, val,
__ATOMIC_RELAXED)
#define atomic_set_release(obj, val) ATOMIC_FUNC(store, 4)(obj, val,
__ATOMIC_RELEASE)
#define atomic64_set(obj, val) ATOMIC_FUNC(store, 8)(obj, val,
__ATOMIC_RELAXED)
@@ -198,6 +207,8 @@ typedef volatile int64_t atomic64_t;
#define atomic64_try_cmpxchg_relaxed(obj, expected, desired) \
ATOMIC_FUNC(compare_exchange_weak, 8)(obj, (FAR int64_t *)expected, desired,
__ATOMIC_RELAXED, __ATOMIC_RELAXED)
+#endif
+
/****************************************************************************
* Public Function Prototypes
****************************************************************************/