Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 1
/*
2
 * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
3
 * It is copyright by its individual contributors, as recorded in the
4
 * project's Git history.  See COPYING.txt at the top level for license
5
 * terms and a link to the Git history.
6
 */
7
#pragma once
8
 
9
#include "dxxsconf.h"
10
 
11
#define _dxx_call_puts_parameter2(A,B,...)      B
12
 
13
#define DXX_CALL_PRINTF_UNWRAP_ARGS_(...)       , ## __VA_ARGS__
14
#define DXX_CALL_PRINTF_DELETE_COMMA2_(A,...)   __VA_ARGS__
15
#define DXX_CALL_PRINTF_DELETE_COMMA_(A,...)    DXX_CALL_PRINTF_DELETE_COMMA2_( A , ## __VA_ARGS__ )
16
 
17
#ifdef DXX_CONSTANT_TRUE
18
#define DXX_PRINTF_CHECK_HAS_NONTRIVIAL_FORMAT_STRING_(V,P,FMT) \
19
        static_cast<void>(DXX_CONSTANT_TRUE((FMT) && (FMT)[0] == '%' && (FMT)[1] == 's' && (FMT)[2] == 0) &&    \
20
                (DXX_ALWAYS_ERROR_FUNCTION(dxx_trap_trivial_string_specifier_argument_##V, "bare %s argument to " #V "; use " #P " directly"), 0))
21
#else
22
#define DXX_PRINTF_CHECK_HAS_NONTRIVIAL_FORMAT_STRING_(V,P,FMT) \
23
        ((void)(FMT))
24
#endif
25
 
26
#define dxx_call_printf_checked(V,P,A,FMT,...)  \
27
        (       \
28
                DXX_PRINTF_CHECK_HAS_NONTRIVIAL_FORMAT_STRING_(V, P, FMT),      \
29
                (sizeof(#__VA_ARGS__) == 1)     ?       \
30
                        (P(DXX_CALL_PRINTF_DELETE_COMMA_(1 DXX_CALL_PRINTF_UNWRAP_ARGS_ A, FMT))) :     \
31
                (V(DXX_CALL_PRINTF_DELETE_COMMA_(1 DXX_CALL_PRINTF_UNWRAP_ARGS_ A, FMT) ,##__VA_ARGS__))        \
32
        )