From a9fc76c848e895ff38116ecb43bf8cd51b0a0078 Mon Sep 17 00:00:00 2001 From: Stuart Ianna Date: Fri, 28 Apr 2023 10:01:46 +1000 Subject: [PATCH] include/err: Enforce c linkage for err and warn functions. This change ensures that xx_func names are not mangled by a c++ compiler and can be correctly resolved when loaded at runtime. --- include/err.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/err.h b/include/err.h index aa748183cd9..fec7f2729fc 100644 --- a/include/err.h +++ b/include/err.h @@ -32,6 +32,14 @@ * Pre-processor Definitions ****************************************************************************/ +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + /* Append _func suffix to avoid the penitential symbol collision */ #define warn warn_func @@ -67,4 +75,9 @@ void verr(int status, FAR const char *fmt, va_list ap) printf_like(2, 0); void errx(int status, FAR const char *fmt, ...) printf_like(2, 3); void verrx(int status, FAR const char *fmt, va_list ap) printf_like(2, 0); +#ifdef __cplusplus +#undef EXTERN +} +#endif + #endif /* __INCLUDE_ERR_H */