2014-06-01 17:55:23 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2013-12-07 01:01:27 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "dxxsconf.h"
|
|
|
|
|
2013-12-19 22:52:03 +00:00
|
|
|
#define _dxx_call_puts_parameter2(A,B,...) B
|
|
|
|
|
2013-12-07 01:01:27 +00:00
|
|
|
#define _dxx_call_printf_unwrap_args(...) , ## __VA_ARGS__
|
|
|
|
#define _dxx_call_printf_delete_comma2(A,...) __VA_ARGS__
|
|
|
|
#define _dxx_call_printf_delete_comma(A,...) _dxx_call_printf_delete_comma2( A , ## __VA_ARGS__ )
|
|
|
|
|
2014-07-19 21:13:30 +00:00
|
|
|
#ifdef DXX_HAVE_BUILTIN_CONSTANT_P
|
2013-12-07 00:35:50 +00:00
|
|
|
#define _dxx_printf_check_has_nontrivial_format_string(V,P,FMT) \
|
|
|
|
((void)((dxx_builtin_constant_p((FMT)) && (FMT)[0] == '%' && (FMT)[1] == 's' && (FMT)[2] == 0) && \
|
2014-07-19 21:13:30 +00:00
|
|
|
(DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_trivial_string_specifier_argument_##V, "bare %s argument to " #V "; use " #P " directly"), 0)))
|
2014-07-15 02:53:23 +00:00
|
|
|
#else
|
|
|
|
#define _dxx_printf_check_has_nontrivial_format_string(V,P,FMT) \
|
|
|
|
((void)(FMT))
|
|
|
|
#endif
|
2013-12-07 00:35:50 +00:00
|
|
|
|
2013-12-07 01:01:27 +00:00
|
|
|
#define dxx_call_printf_checked(V,P,A,FMT,...) \
|
|
|
|
( \
|
2013-12-07 00:35:50 +00:00
|
|
|
_dxx_printf_check_has_nontrivial_format_string(V, P, FMT), \
|
2013-12-07 01:01:27 +00:00
|
|
|
(sizeof(#__VA_ARGS__) == 1) ? \
|
|
|
|
(P(_dxx_call_printf_delete_comma(1 _dxx_call_printf_unwrap_args A, FMT))) : \
|
|
|
|
(V(_dxx_call_printf_delete_comma(1 _dxx_call_printf_unwrap_args A, FMT) ,##__VA_ARGS__)) \
|
|
|
|
)
|