]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/chartype.h
3 * Purpose: Declarations of wxChar and related types
4 * Author: Joel Farley, Ove Kåven
5 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
8 * Copyright: (c) 1998-2006 wxWidgets dev team
9 * Licence: wxWindows licence
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
14 #ifndef _WX_WXCHARTYPE_H_
15 #define _WX_WXCHARTYPE_H_
17 /* defs.h indirectly includes this file, so don't include it here */
18 #include "wx/platform.h"
20 /* check whether we have wchar_t and which size it is if we do */
21 #if !defined(wxUSE_WCHAR_T)
23 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
24 #define wxUSE_WCHAR_T 1
26 #define wxUSE_WCHAR_T 0
28 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
29 #define wxUSE_WCHAR_T 0
30 #elif defined(__WATCOMC__)
31 #define wxUSE_WCHAR_T 0
32 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
33 #define wxUSE_WCHAR_T 0
35 /* add additional compiler checks if this fails */
36 #define wxUSE_WCHAR_T 1
38 #endif /* !defined(wxUSE_WCHAR_T) */
40 /* Unicode support requires wchar_t */
42 #error "wchar_t must be available"
46 non Unix compilers which do have wchar.h (but not tchar.h which is included
47 below and which includes wchar.h anyhow).
49 Actually MinGW has tchar.h, but it does not include wchar.h
51 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
56 #if defined(__MWERKS__) && !defined(__MACH__)
63 /* the current (as of Nov 2002) version of cygwin has a bug in its */
64 /* wchar.h -- there is no extern "C" around the declarations in it */
65 /* and this results in linking errors later; also, at least on some */
66 /* Cygwin versions, wchar.h requires sys/types.h */
68 #include <sys/types.h>
76 #if defined(__CYGWIN__) && defined(__cplusplus)
78 #endif /* Cygwin and C++ */
80 #elif defined(HAVE_WCSTR_H)
81 /* old compilers have relevant declarations here */
83 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
84 /* include stdlib.h for wchar_t */
86 #endif /* HAVE_WCHAR_H */
92 /* -------------------------------------------------------------------------- */
93 /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
94 /* mapped to either char or wchar_t depending on the ASCII/Unicode mode and */
95 /* have the function mapping _tfoo() -> foo() or wfoo() */
96 /* -------------------------------------------------------------------------- */
98 /* VC++ and BC++ starting with 5.2 have TCHAR support */
100 #define wxHAVE_TCHAR_SUPPORT
101 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
102 #define wxHAVE_TCHAR_SUPPORT
104 #elif defined(__WATCOMC__)
105 #define wxHAVE_TCHAR_SUPPORT
106 #elif defined(__DMC__)
107 #define wxHAVE_TCHAR_SUPPORT
108 #elif defined(__WXPALMOS__)
110 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
111 #define wxHAVE_TCHAR_SUPPORT
115 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
116 /* VZ: the old VisualAge definitions were completely wrong and had no */
117 /* chance at all to work in Unicode build anyhow so let's pretend */
118 /* that VisualAge does _not_ support TCHAR for the moment (as */
119 /* indicated by "0 &&" above) until someone really has time to delve */
120 /* into Unicode issues under OS/2 */
122 /* VisualAge 4.0+ supports TCHAR */
123 #define wxHAVE_TCHAR_SUPPORT
124 #endif /* compilers with (good) TCHAR support */
126 #ifdef wxHAVE_TCHAR_SUPPORT
127 /* get TCHAR definition if we've got it */
130 /* we surely do have wchar_t if we have TCHAR */
131 #ifndef wxUSE_WCHAR_T
132 #define wxUSE_WCHAR_T 1
133 #endif /* !defined(wxUSE_WCHAR_T) */
134 #endif /* wxHAVE_TCHAR_SUPPORT */
136 /* ------------------------------------------------------------------------- */
137 /* define wxChar type */
138 /* ------------------------------------------------------------------------- */
140 /* TODO: define wxCharInt to be equal to either int or wint_t? */
144 typedef signed char wxSChar
;
145 typedef unsigned char wxUChar
;
147 /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
148 /* signed/unsigned version of it which (a) makes sense to me (unlike */
149 /* char wchar_t is always unsigned) and (b) was how the previous */
150 /* definitions worked so keep it like this */
152 /* Sun's SunPro compiler supports the wchar_t type and wide character */
153 /* functions, but does not define __WCHAR_TYPE__. Define it here to */
154 /* allow unicode enabled builds. */
155 #if (defined(__SUNPRO_CC) || defined(__SUNPRO_C)) && !defined(__WCHAR_TYPE__)
156 #define __WCHAR_TYPE__ wxchar_t
159 /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
161 #if !defined(__WCHAR_TYPE__) || \
162 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
164 typedef wchar_t wxChar
;
165 typedef wchar_t wxSChar
;
166 typedef wchar_t wxUChar
;
167 #else /* __WCHAR_TYPE__ and gcc < 2.96 */
168 /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. */
169 /* However, this doesn't work with new GCC 3.x compilers because */
170 /* wchar_t is C++'s builtin type in the new standard. OTOH, old */
171 /* compilers (GCC 2.x) won't accept new definition of */
172 /* wx{S,U}CharType, so we have to define wxChar */
173 /* conditionally depending on detected compiler & compiler */
176 /* with old definition of wxChar. */
177 #define wchar_t __WCHAR_TYPE__
178 typedef __WCHAR_TYPE__ wxChar
;
179 typedef __WCHAR_TYPE__ wxSChar
;
180 typedef __WCHAR_TYPE__ wxUChar
;
181 #endif /* __WCHAR_TYPE__ */
182 #endif /* ASCII/Unicode */
184 /* ------------------------------------------------------------------------- */
185 /* define wxStringCharType */
186 /* ------------------------------------------------------------------------- */
188 /* depending on the platform, Unicode build can either store wxStrings as
189 wchar_t* or UTF-8 encoded char*: */
191 /* FIXME-UTF8: what would be better place for this? */
192 #if defined(wxUSE_UTF8_LOCALE_ONLY) && !defined(wxUSE_UNICODE_UTF8)
193 #error "wxUSE_UTF8_LOCALE_ONLY only makes sense with wxUSE_UNICODE_UTF8"
195 #ifndef wxUSE_UTF8_LOCALE_ONLY
196 #define wxUSE_UTF8_LOCALE_ONLY 0
199 #ifndef wxUSE_UNICODE_UTF8
200 #define wxUSE_UNICODE_UTF8 0
203 #if wxUSE_UNICODE_UTF8
204 #define wxUSE_UNICODE_WCHAR 0
206 #define wxUSE_UNICODE_WCHAR 1
209 #define wxUSE_UNICODE_WCHAR 0
210 #define wxUSE_UNICODE_UTF8 0
211 #define wxUSE_UTF8_LOCALE_ONLY 0
214 /* define char type used by wxString internal representation: */
215 #if wxUSE_UNICODE_WCHAR
216 typedef wchar_t wxStringCharType
;
217 #else /* wxUSE_UNICODE_UTF8 || ANSI */
218 typedef char wxStringCharType
;
222 /* ------------------------------------------------------------------------- */
223 /* define wxT() and related macros */
224 /* ------------------------------------------------------------------------- */
226 /* BSD systems define _T() to be something different in ctype.h, override it */
227 #if defined(__FreeBSD__) || defined(__DARWIN__)
233 wxT ("wx text") macro turns a literal string constant into a wide char
234 constant. It is mostly unnecessary with wx 2.9 but defined for
241 /* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
242 #define wxT(x) wxCONCAT_HELPER(L, x)
243 #endif /* ASCII/Unicode */
244 #endif /* !defined(wxT) */
247 wxS ("wx string") macro can be used to create literals using the same
248 representation as wxString does internally, i.e. wchar_t in Unicode build
249 under Windows or char in UTF-8-based Unicode builds and (deprecated) ANSI
250 builds everywhere (see wxStringCharType definition above).
252 #if wxUSE_UNICODE_WCHAR
253 #define wxS(x) wxCONCAT_HELPER(L, x)
254 #else /* wxUSE_UNICODE_UTF8 || ANSI */
259 _T() is a synonym for wxT() familiar to Windows programmers. As this macro
260 has even higher risk of conflicting with system headers, its use is
261 discouraged and you may predefine wxNO__T to disable it. Additionally, we
262 do it ourselves for Sun CC which is known to use it in its standard headers
265 #if defined(__SUNPRO_C) || defined(__SUNPRO_CC)
271 #if !defined(_T) && !defined(wxNO__T)
275 /* a helper macro allowing to make another macro Unicode-friendly, see below */
276 #define wxAPPLY_T(x) wxT(x)
278 /* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
280 #define __TFILE__ wxAPPLY_T(__FILE__)
284 #define __TDATE__ wxAPPLY_T(__DATE__)
288 #define __TTIME__ wxAPPLY_T(__TIME__)
291 #endif /* _WX_WXCHARTYPE_H_ */