]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cpp.h
Rename web library to webview.
[wxWidgets.git] / include / wx / cpp.h
CommitLineData
cdd8d745
VZ
1/*
2 * Name: wx/cpp.h
3 * Purpose: Various preprocessor helpers
4 * Author: Vadim Zeitlin
5 * Created: 2006-09-30
6 * RCS-ID: $Id$
7 * Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 * Licence: wxWindows licence
9 */
10
11/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
12
13#ifndef _WX_CPP_H_
14#define _WX_CPP_H_
15
16/* wxCONCAT works like preprocessor ## operator but also works with macros */
17#define wxCONCAT_HELPER(text, line) text ## line
18#define wxCONCAT(text, line) wxCONCAT_HELPER(text, line)
19
1894e49f
VZ
20#define wxCONCAT3(x1, x2, x3) wxCONCAT(wxCONCAT(x1, x2), x3)
21#define wxCONCAT4(x1, x2, x3, x4) wxCONCAT(wxCONCAT3(x1, x2, x3), x4)
22#define wxCONCAT5(x1, x2, x3, x4, x5) wxCONCAT(wxCONCAT4(x1, x2, x3, x4), x5)
23
cdd8d745
VZ
24/* wxSTRINGIZE works as the preprocessor # operator but also works with macros */
25#define wxSTRINGIZE_HELPER(x) #x
26#define wxSTRINGIZE(x) wxSTRINGIZE_HELPER(x)
27
84206bbb
VZ
28/* a Unicode-friendly version of wxSTRINGIZE_T */
29#define wxSTRINGIZE_T(x) wxAPPLY_T(wxSTRINGIZE(x))
30
25859335
VZ
31/*
32 Special workarounds for compilers with broken "##" operator. For all the
33 other ones we can just use it directly.
34 */
35#ifdef wxCOMPILER_BROKEN_CONCAT_OPER
36 #define wxPREPEND_L(x) L ## x
37 #define wxAPPEND_i64(x) x ## i64
38 #define wxAPPEND_ui64(x) x ## ui64
39#endif /* wxCOMPILER_BROKEN_CONCAT_OPER */
40
cdd8d745
VZ
41/*
42 Helper macros for wxMAKE_UNIQUE_NAME: normally this works by appending the
43 current line number to the given identifier to reduce the probability of the
44 conflict (it may still happen if this is used in the headers, hence you
45 should avoid doing it or provide unique prefixes then) but we have to do it
46 differently for VC++
47 */
48#if defined(__VISUALC__) && (__VISUALC__ >= 1300)
49 /*
50 __LINE__ handling is completely broken in VC++ when using "Edit and
51 Continue" (/ZI option) and results in preprocessor errors if we use it
52 inside the macros. Luckily VC7 has another standard macro which can be
53 used like this and is even better than __LINE__ because it is globally
54 unique.
55 */
56# define wxCONCAT_LINE(text) wxCONCAT(text, __COUNTER__)
57#else /* normal compilers */
58# define wxCONCAT_LINE(text) wxCONCAT(text, __LINE__)
59#endif
60
61/* Create a "unique" name with the given prefix */
62#define wxMAKE_UNIQUE_NAME(text) wxCONCAT_LINE(text)
63
bde626ce
VZ
64/*
65 This macro can be passed as argument to another macro when you don't have
66 anything to pass in fact.
67 */
68#define wxEMPTY_PARAMETER_VALUE /* Fake macro parameter value */
69
a6ebdba6
VZ
70/*
71 Define __WXFUNCTION__ which is like standard __FUNCTION__ but defined as
72 NULL for the compilers which don't support the latter.
73 */
74#ifndef __WXFUNCTION__
75 /* TODO: add more compilers supporting __FUNCTION__ */
76 #if defined(__DMC__)
77 /*
78 __FUNCTION__ happens to be not defined within class members
79 http://www.digitalmars.com/drn-bin/wwwnews?c%2B%2B.beta/485
80 */
81 #define __WXFUNCTION__ (NULL)
82 #elif defined(__GNUC__) || \
83 (defined(_MSC_VER) && _MSC_VER >= 1300) || \
84 defined(__FUNCTION__)
85 #define __WXFUNCTION__ __FUNCTION__
86 #else
87 /* still define __WXFUNCTION__ to avoid #ifdefs elsewhere */
88 #define __WXFUNCTION__ (NULL)
89 #endif
90#endif /* __WXFUNCTION__ already defined */
91
28efe654 92#endif /* _WX_CPP_H_ */
cdd8d745 93