master
1#ifndef PFORMAT_H
2/*
3 * pformat.h
4 *
5 * $Id: pformat.h,v 1.1 2008/07/28 23:24:20 keithmarshall Exp $
6 *
7 * A private header, defining the `pformat' API; it is to be included
8 * in each compilation unit implementing any of the `printf' family of
9 * functions, but serves no useful purpose elsewhere.
10 *
11 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
12 *
13 * This is free software. You may redistribute and/or modify it as you
14 * see fit, without restriction of copyright.
15 *
16 * This software is provided "as is", in the hope that it may be useful,
17 * but WITHOUT WARRANTY OF ANY KIND, not even any implied warranty of
18 * MERCHANTABILITY, nor of FITNESS FOR ANY PARTICULAR PURPOSE. At no
19 * time will the author accept any form of liability for any damages,
20 * however caused, resulting from the use of this software.
21 */
22#define PFORMAT_H
23
24/* The following macros reproduce definitions from _mingw.h,
25 * so that compilation will not choke, if using any compiler
26 * other than the MinGW implementation of GCC.
27 */
28#ifndef __cdecl
29# ifdef __GNUC__
30# define __cdecl __attribute__((__cdecl__))
31# else
32# define __cdecl
33# endif
34#endif
35
36#ifndef __MINGW_GNUC_PREREQ
37# if defined __GNUC__ && defined __GNUC_MINOR__
38# define __MINGW_GNUC_PREREQ( major, minor )\
39 (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
40# else
41# define __MINGW_GNUC_PREREQ( major, minor )
42# endif
43#endif
44
45#ifndef __MINGW_NOTHROW
46# if __MINGW_GNUC_PREREQ( 3, 3 )
47# define __MINGW_NOTHROW __attribute__((__nothrow__))
48# else
49# define __MINGW_NOTHROW
50# endif
51#endif
52
53#ifdef __BUILD_WIDEAPI
54#define APICHAR wchar_t
55#else
56#define APICHAR char
57#endif
58
59/* The following are the declarations specific to the `pformat' API...
60 */
61#define PFORMAT_TO_FILE 0x2000
62#define PFORMAT_NOLIMIT 0x4000
63
64#if defined(__MINGW32__) || defined(__MINGW64__)
65 /*
66 * Map MinGW specific function names, for use in place of the generic
67 * implementation defined equivalent function names.
68 */
69#ifdef __BUILD_WIDEAPI
70# define __pformat __mingw_wpformat
71#define __fputc(X,STR) fputwc((wchar_t) (X), (STR))
72
73# define __printf __mingw_wprintf
74# define __fprintf __mingw_fwprintf
75#ifdef __BUILD_WIDEAPI_ISO
76# define __snprintf __mingw_swprintf
77#else
78# define __snprintf __mingw_snwprintf
79#endif
80
81# define __vprintf __mingw_vwprintf
82# define __vfprintf __mingw_vfwprintf
83#ifdef __BUILD_WIDEAPI_ISO
84# define __vsnprintf __mingw_vswprintf
85#else
86# define __vsnprintf __mingw_vsnwprintf
87#endif
88
89#else
90# define __pformat __mingw_pformat
91#define __fputc(X,STR) fputc((X), (STR))
92
93# define __printf __mingw_printf
94# define __fprintf __mingw_fprintf
95# define __sprintf __mingw_sprintf
96# define __snprintf __mingw_snprintf
97
98# define __vprintf __mingw_vprintf
99# define __vfprintf __mingw_vfprintf
100# define __vsprintf __mingw_vsprintf
101# define __vsnprintf __mingw_vsnprintf
102#endif /* __BUILD_WIDEAPI */
103#endif
104
105int __cdecl __pformat(int, void *, int, const APICHAR *, va_list) __MINGW_NOTHROW;
106#endif /* !defined PFORMAT_H */