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.
This commit is contained in:
Stuart Ianna 2023-04-28 10:01:46 +10:00 committed by Xiang Xiao
parent f7d64fec9f
commit a9fc76c848

View File

@ -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 */