From e982488e6cb5001dff41f4289b5da83d7c750f7d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 19 Feb 2019 09:04:04 -0600 Subject: [PATCH] include/nuttx/compiler.h: Important fix for C++ users. compiler.h was using the value of __STDC_VERSION__ to determine if inline functions are supported or not. If not then the keyword inline was defined out. Good for C but bad for C++ because C++ does not defined __STDC_VERSION__ at all. C++ applications may draw in compiler.h indirectly via other head files and this can result in C++ compiler problems since 'inline' is defined out. This fix is to ignore the (undefined) __STDC_VERSION__ if __cplusplus is defined. --- include/nuttx/compiler.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 6936892daa..6b749e9ed1 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -260,7 +260,7 @@ /* GCC supports inlined functions for version C99 and above */ -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +# if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) # define CONFIG_HAVE_INLINE 1 # else # undef CONFIG_HAVE_INLINE @@ -273,7 +273,7 @@ # undef CONFIG_HAVE_ANONYMOUS_STRUCT # undef CONFIG_HAVE_ANONYMOUS_UNION -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +# if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) # define CONFIG_HAVE_ANONYMOUS_STRUCT 1 # define CONFIG_HAVE_ANONYMOUS_UNION 1 # endif