nshlib/nsh_console.h: Add nsh_none, where any empty output can be forwarded
Add nsh_none to consume all empty traces from nsh. For the variadic argument case need to add a (inline) function to eat away the __VA_ARGS__ list, there is no good / portable way to do this by pre-processor macros, but a function will eat the variadic list whatever its size is.
This commit is contained in:
parent
1668c3e97d
commit
94d477b3df
@ -53,18 +53,17 @@
|
|||||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||||
# define nsh_error(v, ...) (v)->error(v, ##__VA_ARGS__)
|
# define nsh_error(v, ...) (v)->error(v, ##__VA_ARGS__)
|
||||||
# define nsh_output(v, ...) (v)->output(v, ##__VA_ARGS__)
|
# define nsh_output(v, ...) (v)->output(v, ##__VA_ARGS__)
|
||||||
|
# define nsh_none(v, ...) \
|
||||||
|
do { if (0) nsh_output_none(v, ##__VA_ARGS__); } while (0)
|
||||||
#else
|
#else
|
||||||
# define nsh_error vtbl->error
|
# define nsh_error vtbl->error
|
||||||
# define nsh_output vtbl->output
|
# define nsh_output vtbl->output
|
||||||
|
# define nsh_none (void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NSH_DISABLE_ERROR_PRINT
|
#ifdef CONFIG_NSH_DISABLE_ERROR_PRINT
|
||||||
# undef nsh_error
|
# undef nsh_error
|
||||||
# ifdef CONFIG_CPP_HAVE_VARARGS
|
# define nsh_error nsh_none
|
||||||
# define nsh_error(v, ...) (void)(v)
|
|
||||||
# else
|
|
||||||
# define nsh_error (void)(vtbl)
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Size of info to be saved in call to nsh_redirect
|
/* Size of info to be saved in call to nsh_redirect
|
||||||
@ -183,6 +182,19 @@ struct console_stdio_s
|
|||||||
* Public Data
|
* Public Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Inline functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_CPP_HAVE_VARARGS
|
||||||
|
/* Can be used to suppress any nsh output */
|
||||||
|
|
||||||
|
static inline void nsh_output_none(FAR struct nsh_vtbl_s *vtbl, ...)
|
||||||
|
{
|
||||||
|
UNUSED(vtbl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user