From 2fa607796d5869f84a9fd24b437c2b39227c5a48 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Tue, 5 Aug 2025 17:15:24 +0300 Subject: [PATCH] include/nuttx/atomic.h: Fix C++ compilation with -nostdinc++ Without c++ standard includes, the library is not available. GCC may use __auto_type for the C-style atomic oprations, and this is not available for C++. Just define the __auto_type to auto for C++. Also, the built-in _atomic functions for GCC expect "volatile" parameters in C, but don't allow that in C++. So selecting the atomic_t and atomic64_t types according to that. Signed-off-by: Jukka Laitinen --- include/nuttx/atomic.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/nuttx/atomic.h b/include/nuttx/atomic.h index 53b24b02a11..79d475f0189 100644 --- a/include/nuttx/atomic.h +++ b/include/nuttx/atomic.h @@ -60,8 +60,14 @@ extern "C++" # include # define ATOMIC_FUNC(f, n) atomic_##f##_explicit - typedef volatile _Atomic int32_t atomic_t; - typedef volatile _Atomic int64_t atomic64_t; +# if defined(__cplusplus) +# define __auto_type auto +typedef _Atomic int32_t atomic_t; +typedef _Atomic int64_t atomic64_t; +# else +typedef volatile _Atomic int32_t atomic_t; +typedef volatile _Atomic int64_t atomic64_t; +# endif # endif #endif