You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1044 lines
42 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/winstl.h
  3. *
  4. * Purpose: Root header for the WinSTL libraries. Performs various compiler
  5. * and platform discriminations, and definitions of types.
  6. *
  7. * Created: 15th January 2002
  8. * Updated: 20th March 2012
  9. *
  10. * Home: http://stlsoft.org/
  11. *
  12. * Copyright (c) 2002-2012, Matthew Wilson and Synesis Software
  13. * All rights reserved.
  14. *
  15. * Redistribution and use in source and binary forms, with or without
  16. * modification, are permitted provided that the following conditions are
  17. * met:
  18. *
  19. * - Redistributions of source code must retain the above copyright notice,
  20. * this list of conditions and the following disclaimer.
  21. * - Redistributions in binary form must reproduce the above copyright
  22. * notice, this list of conditions and the following disclaimer in the
  23. * documentation and/or other materials provided with the distribution.
  24. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
  25. * names of any contributors may be used to endorse or promote products
  26. * derived from this software without specific prior written permission.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
  29. * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  30. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  31. * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  32. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  33. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  34. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  35. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  36. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  37. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. *
  40. * ////////////////////////////////////////////////////////////////////// */
  41. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  42. #define WINSTL_INCL_WINSTL_H_WINSTL
  43. #define WINSTL_INCL_H_WINSTL /*!< \brief Definition of previous include-guard symbol for winstl/winstl.h, for backwards compatibility. */
  44. /* File version */
  45. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  46. # define WINSTL_VER_WINSTL_H_WINSTL_MAJOR 3
  47. # define WINSTL_VER_WINSTL_H_WINSTL_MINOR 14
  48. # define WINSTL_VER_WINSTL_H_WINSTL_REVISION 1
  49. # define WINSTL_VER_WINSTL_H_WINSTL_EDIT 190
  50. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  51. /** \file winstl/winstl.h
  52. *
  53. * \brief [C, C++] The root header for the \ref group__project__winstl "WinSTL" project.
  54. */
  55. /* /////////////////////////////////////////////////////////////////////////
  56. * WinSTL version
  57. *
  58. * The libraries version information is comprised of major, minor and revision
  59. * components.
  60. *
  61. * The major version is denoted by the _WINSTL_VER_MAJOR preprocessor symbol.
  62. * A changes to the major version component implies that a dramatic change has
  63. * occurred in the libraries, such that considerable changes to source dependent
  64. * on previous versions would need to be effected.
  65. *
  66. * The minor version is denoted by the _WINSTL_VER_MINOR preprocessor symbol.
  67. * Changes to the minor version component imply that a significant change has
  68. * occurred to the libraries, either in the addition of new functionality or in
  69. * the destructive change to one or more components such that recomplilation and
  70. * code change may be necessitated.
  71. *
  72. * The revision version is denoted by the _WINSTL_VER_REVISION preprocessor
  73. * symbol. Changes to the revision version component imply that a bug has been
  74. * fixed. Dependent code should be recompiled in order to pick up the changes.
  75. *
  76. * In addition to the individual version symbols - _WINSTL_VER_MAJOR,
  77. * _WINSTL_VER_MINOR and _WINSTL_VER_REVISION - a composite symbol _WINSTL_VER
  78. * is defined, where the upper 8 bits are 0, bits 16-23 represent the major
  79. * component, bits 8-15 represent the minor component, and bits 0-7 represent
  80. * the revision component.
  81. *
  82. * Each release of the libraries will bear a different version, and that version
  83. * will also have its own symbol: Version 1.0.1 specifies _WINSTL_VER_1_0_1.
  84. *
  85. * Thus the symbol _WINSTL_VER may be compared meaningfully with a specific
  86. * version symbol, e.g. #if _WINSTL_VER >= _WINSTL_VER_1_0_1
  87. */
  88. /** \def _WINSTL_VER_MAJOR
  89. * \brief The major version number of the \ref group__project__winstl project "WinSTL" project
  90. */
  91. /** \def _WINSTL_VER_MINOR
  92. * \brief The minor version number of the \ref group__project__winstl project "WinSTL" project
  93. */
  94. /** \def _WINSTL_VER_REVISION
  95. * \brief The revision version number of the \ref group__project__winstl project "WinSTL" project
  96. */
  97. /** \def _WINSTL_VER
  98. * \brief The current composite version number of the \ref group__project__winstl project "WinSTL" project
  99. */
  100. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  101. # define _WINSTL_VER_1_0_1 0x00010001 /*!< Version 1.0.1 */
  102. # define _WINSTL_VER_1_0_2 0x00010002 /*!< Version 1.0.2 */
  103. # define _WINSTL_VER_1_1_1 0x00010101 /*!< Version 1.1.1 */
  104. # define _WINSTL_VER_1_2_1 0x00010201 /*!< Version 1.2.1 */
  105. # define _WINSTL_VER_1_3_1 0x00010301 /*!< Version 1.3.1 */
  106. # define _WINSTL_VER_1_3_2 0x00010302 /*!< Version 1.3.2 */
  107. # define _WINSTL_VER_1_3_3 0x00010303 /*!< Version 1.3.3 */
  108. # define _WINSTL_VER_1_3_4 0x00010304 /*!< Version 1.3.4 */
  109. # define _WINSTL_VER_1_3_5 0x00010305 /*!< Version 1.3.5 */
  110. # define _WINSTL_VER_1_3_6 0x00010306 /*!< Version 1.3.6 */
  111. # define _WINSTL_VER_1_3_7 0x00010307 /*!< Version 1.3.7 */
  112. # define _WINSTL_VER_1_4_1 0x00010401 /*!< Version 1.4.1 */
  113. # define _WINSTL_VER_1_5_1 0x00010501 /*!< Version 1.5.1 */
  114. # define _WINSTL_VER_1_5_2 0x00010502 /*!< Version 1.5.2 */
  115. # define _WINSTL_VER_1_6_1 0x00010601 /*!< Version 1.6.1 */
  116. # define _WINSTL_VER_1_6_2 0x00010602 /*!< Version 1.6.2 */
  117. # define _WINSTL_VER_1_6_3 0x00010603 /*!< Version 1.6.3 */
  118. # define _WINSTL_VER_1_6_4 0x00010604 /*!< Version 1.6.4 */
  119. # define _WINSTL_VER_1_6_5 0x00010605 /*!< Version 1.6.5 */
  120. # define _WINSTL_VER_1_7_1 0x00010701 /*!< Version 1.7.1 */
  121. # define _WINSTL_VER_1_8_1 0x00010801 /*!< Version 1.8.1 */
  122. # define _WINSTL_VER_1_8_2 0x00010802 /*!< Version 1.8.2 */
  123. # define _WINSTL_VER_1_9_1 0x00010901 /*!< Version 1.9.1 (with STLSoft 1.9.1) */
  124. # define _WINSTL_VER_1_9_2 0x00010902 /*!< Version 1.9.2 (with STLSoft 1.9.7) */
  125. # define _WINSTL_VER_1_9_3 0x00010903 /*!< Version 1.9.3 (with STLSoft 1.9.25) */
  126. # define _WINSTL_VER_1_9_4 0x010904ff /*!< Version 1.9.4 (with STLSoft 1.9.30) */
  127. # define _WINSTL_VER_1_9_5 0x010905ff /*!< Version 1.9.5 (with STLSoft 1.9.31) */
  128. # define _WINSTL_VER_1_9_6 0x010906ff /*!< Version 1.9.6 (with STLSoft 1.9.32) */
  129. # define _WINSTL_VER_1_10_1 0x010a01ff /*!< Version 1.10.1 (with STLSoft 1.9.37) */
  130. # define _WINSTL_VER_1_10_2 0x010a02ff /*!< Version 1.10.2 (with STLSoft 1.9.42) */
  131. # define _WINSTL_VER_1_10_3 0x010a03ff /*!< Version 1.10.3 (with STLSoft 1.9.82) */
  132. # define _WINSTL_VER_1_10_4 0x010a04ff /*!< Version 1.10.4 (with STLSoft 1.9.84) */
  133. # define _WINSTL_VER_1_10_5 0x010a05ff /*!< Version 1.10.5 (with STLSoft 1.9.88) */
  134. # define _WINSTL_VER_1_10_6 0x010a06ff /*!< Version 1.10.6 (with STLSoft 1.9.90) */
  135. # define _WINSTL_VER_1_10_7 0x010a07ff /*!< Version 1.10.7 (with STLSoft 1.9.91) */
  136. # define _WINSTL_VER_1_11_1 0x010b01ff /*!< Version 1.11.1 (with STLSoft 1.9.93) */
  137. # define _WINSTL_VER_1_11_2 0x010b02ff /*!< Version 1.11.2 (with STLSoft 1.9.100) */
  138. # define _WINSTL_VER_1_11_3 0x010b03ff /*!< Version 1.11.3 (with STLSoft 1.9.101) */
  139. # define _WINSTL_VER_1_11_4 0x010b04ff /*!< Version 1.11.4 (with STLSoft 1.9.105) */
  140. # define _WINSTL_VER_1_11_5 0x010b05ff /*!< Version 1.11.5 (with STLSoft 1.9.107) */
  141. # define _WINSTL_VER_1_11_6 0x010b06ff /*!< Version 1.11.6 (with STLSoft 1.9.108) */
  142. # define _WINSTL_VER_1_11_7 0x010b07ff /*!< Version 1.11.7 (with STLSoft 1.9.109) */
  143. # define _WINSTL_VER_1_11_8 0x010b08ff /*!< Version 1.11.8 (with STLSoft 1.9.113) */
  144. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  145. #define _WINSTL_VER_MAJOR 1
  146. #define _WINSTL_VER_MINOR 11
  147. #define _WINSTL_VER_REVISION 8
  148. #define _WINSTL_VER _WINSTL_VER_1_11_8
  149. /* /////////////////////////////////////////////////////////////////////////
  150. * Includes
  151. */
  152. /* Strict */
  153. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  154. # ifndef STRICT
  155. # if defined(_WINSTL_STRICT) || \
  156. ( !defined(_WINSTL_NO_STRICT) && \
  157. !defined(NO_STRICT))
  158. # define STRICT 1
  159. # endif /* !NO_STRICT && !_WINSTL_NO_STRICT */
  160. # endif /* STRICT */
  161. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  162. #ifndef STLSOFT_INCL_STLSOFT_H_STLSOFT
  163. # include <stlsoft/stlsoft.h>
  164. #endif /* !STLSOFT_INCL_STLSOFT_H_STLSOFT */
  165. #if defined(STLSOFT_COMPILER_IS_MSVC) && \
  166. _MSC_VER == 1100
  167. # include <wtypes.h> /* This is here to fix a thoroughly inexplicable VC 5 bug */
  168. #endif /* compiler */
  169. #if defined(STLSOFT_COMPILER_IS_GCC) && \
  170. defined(_WIN32) && \
  171. ( defined(WIN32) || \
  172. defined(WIN64))
  173. # ifndef STLSOFT_INCL_H_BASETYPS
  174. # define STLSOFT_INCL_H_BASETYPS
  175. # include <basetyps.h>
  176. # endif /* !STLSOFT_INCL_H_BASETYPS */
  177. # ifndef STLSOFT_INCL_H_WTYPES
  178. # define STLSOFT_INCL_H_WTYPES
  179. # include <wtypes.h>
  180. # endif /* !STLSOFT_INCL_H_WTYPES */
  181. # ifndef STLSOFT_INCL_H_OLEAUTO
  182. # define STLSOFT_INCL_H_OLEAUTO
  183. # include <oleauto.h>
  184. # endif /* !STLSOFT_INCL_H_OLEAUTO */
  185. # ifndef STLSOFT_INCL_H_OAIDL
  186. # define STLSOFT_INCL_H_OAIDL
  187. # include <oaidl.h>
  188. # endif /* !STLSOFT_INCL_H_OAIDL */
  189. #endif /* compiler */
  190. #ifndef STLSOFT_INCL_H_WINDOWS
  191. # define STLSOFT_INCL_H_WINDOWS
  192. # include <windows.h> /* Windows base header */
  193. #endif /* !STLSOFT_INCL_H_WINDOWS */
  194. /* Intel is super pernickety about conversions, so we need to bring out the union_cast. */
  195. #if defined(STLSOFT_COMPILER_IS_INTEL) && \
  196. defined(__cplusplus)
  197. # ifndef STLSOFT_INCL_STLSOFT_CONVERSION_HPP_UNION_CAST
  198. # include <stlsoft/conversion/union_cast.hpp>
  199. # endif /* !STLSOFT_INCL_STLSOFT_CONVERSION_HPP_UNION_CAST */
  200. #endif /* compiler */
  201. #ifndef STLSOFT_INCL_H_STDLIB
  202. # define STLSOFT_INCL_H_STDLIB
  203. # include <stdlib.h> /* for MAX_PATH (CygWin) */
  204. #endif /* !STLSOFT_INCL_H_STDLIB */
  205. /* /////////////////////////////////////////////////////////////////////////
  206. * STLSoft version compatibility
  207. */
  208. #if !defined(_STLSOFT_VER) || \
  209. _STLSOFT_VER < 0x010971ff
  210. # error This version of the WinSTL libraries requires STLSoft version 1.9.113, or later
  211. #endif /* _STLSOFT_VER */
  212. /* /////////////////////////////////////////////////////////////////////////
  213. * Operating System
  214. */
  215. #ifdef WINSTL_OS_IS_WIN32
  216. # undef WINSTL_OS_IS_WIN32
  217. #endif /* WINSTL_OS_IS_WIN32 */
  218. #ifdef WINSTL_OS_IS_WIN64
  219. # undef WINSTL_OS_IS_WIN64
  220. #endif /* WINSTL_OS_IS_WIN64 */
  221. #if defined(WIN64) || \
  222. defined(_WIN64)
  223. # if !defined(WIN64)
  224. # ifdef STLSOFT_COMPILE_VERBOSE
  225. # pragma message("Win64 platform targeted, as indicated by definition of _WIN64, but WIN64 is not defined: adjust your project/make settings to define WIN64")
  226. # endif /* STLSOFT_COMPILE_VERBOSE */
  227. # endif /* !WIN64 */
  228. # define WINSTL_OS_IS_WIN64
  229. # if !defined(_WIN64)
  230. # error Compiling with WIN64 defined and _WIN64 not defined. Are you using the wrong makefile?
  231. # endif /* !_WIN64 */
  232. #elif defined(WIN32)
  233. # define WINSTL_OS_IS_WIN32
  234. #else /* ? WIN?? */
  235. # error WinSTL is only compatible with Win32 and Win64
  236. #endif /* WIN?? */
  237. /* /////////////////////////////////////////////////////////////////////////
  238. * Architecture
  239. */
  240. #ifdef WINSTL_ARCH_IS_X86
  241. # undef WINSTL_ARCH_IS_X86
  242. #endif /* WINSTL_ARCH_IS_X86 */
  243. #ifdef WINSTL_ARCH_IS_IA64
  244. # undef WINSTL_ARCH_IS_IA64
  245. #endif /* WINSTL_ARCH_IS_IA64 */
  246. #ifdef WINSTL_ARCH_IS_X64
  247. # undef WINSTL_ARCH_IS_X64
  248. #endif /* WINSTL_ARCH_IS_X64 */
  249. #if defined(_M_IA64)
  250. # define WINSTL_ARCH_IS_IA64
  251. #elif defined(_M_X64) || \
  252. defined(_M_AMD64)
  253. # define WINSTL_ARCH_IS_X64
  254. #elif defined(_M_IX86)
  255. # define WINSTL_ARCH_IS_X86
  256. #else /* ? _M_?? */
  257. # error WinSTL is only compatible with x86, IA64 and x64 architectures
  258. #endif /* _M_?? */
  259. /* /////////////////////////////////////////////////////////////////////////
  260. * Proper C++ casting
  261. */
  262. #ifdef __cplusplus
  263. # undef INVALID_HANDLE_VALUE
  264. /** \def INVALID_HANDLE_VALUE
  265. * \brief A C++-only redefinition of this \#define which uses reinterpret_cast to
  266. * avoid C-style cast warnings.
  267. */
  268. # if defined(STLSOFT_COMPILER_IS_INTEL)
  269. # define INVALID_HANDLE_VALUE stlsoft_ns_qual(union_cast)<HANDLE>(winstl_ns_qual(ws_sptrint_t)(-1))
  270. # else /* ? compiler */
  271. # define INVALID_HANDLE_VALUE reinterpret_cast<HANDLE>(-1)
  272. # endif /* compiler */
  273. /** \def MAKEINTRESOURCEA
  274. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  275. * avoid C-style cast warnings.
  276. */
  277. # undef MAKEINTRESOURCEA
  278. # if defined(_WIN64) || \
  279. defined(_Wp64)
  280. # define MAKEINTRESOURCEA(i) reinterpret_cast<LPSTR>(static_cast<ULONG_PTR>(static_cast<WORD>(i)))
  281. # else /* ? width */
  282. # define MAKEINTRESOURCEA(i) reinterpret_cast<LPSTR>(static_cast<ULONG>(static_cast<WORD>(i)))
  283. # endif /* width */
  284. /** \def MAKEINTRESOURCEW
  285. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  286. * avoid C-style cast warnings.
  287. */
  288. # undef MAKEINTRESOURCEW
  289. # if defined(_WIN64) || \
  290. defined(_Wp64)
  291. # define MAKEINTRESOURCEW(i) reinterpret_cast<LPWSTR>(static_cast<ULONG_PTR>(static_cast<WORD>(i)))
  292. # else /* ? width */
  293. # define MAKEINTRESOURCEW(i) reinterpret_cast<LPWSTR>(static_cast<ULONG>(static_cast<WORD>(i)))
  294. # endif /* width */
  295. /** \def MAKEINTRESOURCE
  296. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  297. * avoid C-style cast warnings.
  298. */
  299. # undef MAKEINTRESOURCE
  300. # if defined(_WIN64) || \
  301. defined(_Wp64)
  302. # define MAKEINTRESOURCE(i) reinterpret_cast<LPTSTR>(static_cast<ULONG_PTR>(static_cast<WORD>(i)))
  303. # else /* ? width */
  304. # define MAKEINTRESOURCE(i) reinterpret_cast<LPTSTR>(static_cast<ULONG>(static_cast<WORD>(i)))
  305. # endif /* width */
  306. /** \def MAKELANGID
  307. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  308. * avoid C-style cast warnings.
  309. */
  310. # undef MAKELANGID
  311. # define MAKELANGID(p, s) ((static_cast<DWORD>(static_cast<WORD>(s)) << 10) | static_cast<WORD>(p))
  312. /* # undef LOWORD */
  313. /* # define LOWORD(l) static_cast<WORD>(static_cast<DWORD>(l) & 0xffff) */
  314. /** \def INVALID_FILE_SIZE
  315. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  316. * avoid C-style cast warnings.
  317. */
  318. # undef INVALID_FILE_SIZE
  319. # define INVALID_FILE_SIZE static_cast<DWORD>(0xFFFFFFFF)
  320. /** \def INVALID_SET_FILE_POINTER
  321. * \brief A C++-only redefinition of this \#define which uses C++ cast operators to
  322. * avoid C-style cast warnings.
  323. */
  324. # undef INVALID_SET_FILE_POINTER
  325. # define INVALID_SET_FILE_POINTER static_cast<DWORD>(0xFFFFFFFF)
  326. #else /* ? __cplusplus */
  327. # ifndef INVALID_SET_FILE_POINTER
  328. # define INVALID_SET_FILE_POINTER stlsoft_c_cast(DWORD, -1)
  329. # endif /* !INVALID_SET_FILE_POINTER */
  330. # ifndef INVALID_FILE_ATTRIBUTES
  331. # define INVALID_FILE_ATTRIBUTES stlsoft_c_cast(DWORD, -1)
  332. # endif /* !INVALID_FILE_ATTRIBUTES */
  333. #endif /* __cplusplus */
  334. /* /////////////////////////////////////////////////////////////////////////
  335. * Sanity checks
  336. *
  337. * Win32 - must be compiled in context of Win32 API
  338. */
  339. /* Must be Win32 api. */
  340. #if !defined(WIN32) && \
  341. !defined(_WIN32)
  342. # error The WinSTL libraries is currently only compatible with the Win32 API
  343. #endif /* !WIN32 && !_WIN32 */
  344. /* /////////////////////////////////////////////////////////////////////////
  345. * Compiler compatibility
  346. *
  347. * Currently the only compilers supported by the WinSTL libraries are
  348. *
  349. * Borland C++ 5.5, 5.51, 5.6
  350. * Digital Mars C/C++ 8.26 - 8.32
  351. * Metrowerks 2.4 & 3.0 (CodeWarrior 7.0 & 8.0)
  352. * Intel C/C++ 6.0 & 7.0
  353. * Visual C++ 4.2, 5.0, 6.0, 7.0
  354. * Watcom C/C++ 11.0
  355. */
  356. #if defined(STLSOFT_COMPILER_IS_BORLAND)
  357. /* Borland C++ */
  358. # if __BORLANDC__ < 0x0550
  359. # error Versions of Borland C++ prior to 5.5 are not supported by the WinSTL libraries
  360. # endif /* __BORLANDC__ */
  361. #elif defined(STLSOFT_COMPILER_IS_COMO)
  362. /* Comeau C++ */
  363. # if __COMO_VERSION__ < 4300
  364. # error Versions of Comeau C++ prior to 4.3 are not supported by the WinSTL libraries
  365. # endif /* __COMO_VERSION__ */
  366. #elif defined(STLSOFT_COMPILER_IS_DMC)
  367. /* Digital Mars C/C++ */
  368. # if __DMC__ < 0x0826
  369. # error Versions of Digital Mars C/C++ prior to 8.26 are not supported by the WinSTL libraries
  370. # endif /* __DMC__ */
  371. #elif defined(STLSOFT_COMPILER_IS_GCC)
  372. /* GNU C/C++ */
  373. # if __GNUC__ < 3
  374. # error Versions of GNU C/C++ prior to 3.0 are not supported by the WinSTL libraries
  375. # endif /* __GNUC__ */
  376. #elif defined(STLSOFT_COMPILER_IS_INTEL)
  377. /* Intel C++ */
  378. # if (__INTEL_COMPILER < 600)
  379. # error Versions of Intel C++ prior to 6.0 are not supported by the WinSTL libraries
  380. # endif /* __INTEL_COMPILER */
  381. #elif defined(STLSOFT_COMPILER_IS_MWERKS)
  382. /* Metrowerks C++ */
  383. # if (__MWERKS__ & 0xFF00) < 0x2400
  384. # error Versions of Metrowerks CodeWarrior C++ prior to 7.0 are not supported by the WinSTL libraries
  385. # endif /* __MWERKS__ */
  386. #elif defined(STLSOFT_COMPILER_IS_MSVC)
  387. /* Visual C++ */
  388. # if _MSC_VER < 1020
  389. # error Versions of Visual C++ prior to 4.2 are not supported by the WinSTL libraries
  390. # endif /* _MSC_VER */
  391. #elif defined(STLSOFT_COMPILER_IS_VECTORC)
  392. /* VectorC C/C++ */
  393. #elif defined(STLSOFT_COMPILER_IS_WATCOM)
  394. /* Watcom C/C++ */
  395. # if (__WATCOMC__ < 1200)
  396. # error Versions of Watcom C/C++ prior to 12.0 are not supported by the WinSTL libraries
  397. # endif /* __WATCOMC__ */
  398. #else
  399. /* No recognised compiler */
  400. # ifdef _STLSOFT_FORCE_ANY_COMPILER
  401. # define _WINSTL_COMPILER_IS_UNKNOWN
  402. # ifdef STLSOFT_COMPILE_VERBOSE
  403. # pragma message("Compiler is unknown to WinSTL")
  404. # endif /* STLSOFT_COMPILE_VERBOSE */
  405. # else
  406. # error Currently only Borland C++, Comeau, Digital Mars C/C++, GNU C++, Intel C/C++, Metrowerks CodeWarrior, Visual C++ and Watcom compilers are supported by the WinSTL libraries
  407. # endif /* _STLSOFT_FORCE_ANY_COMPILER */
  408. #endif /* compiler */
  409. /* /////////////////////////////////////////////////////////////////////////
  410. * Features
  411. */
  412. #ifdef WINSTL_UDATE_DEFINED
  413. # undef WINSTL_UDATE_DEFINED
  414. #endif /* WINSTL_UDATE_DEFINED */
  415. #if defined(WINSTL_FORCE_UDATE) || \
  416. defined(STLSOFT_COMPILER_IS_BORLAND) || \
  417. ( defined(STLSOFT_COMPILER_IS_COMO) && \
  418. defined(_MSC_VER)) || \
  419. defined(STLSOFT_COMPILER_IS_DMC) || \
  420. defined(STLSOFT_COMPILER_IS_INTEL) || \
  421. defined(STLSOFT_COMPILER_IS_MWERKS) || \
  422. defined(STLSOFT_COMPILER_IS_MSVC)
  423. # define WINSTL_UDATE_DEFINED
  424. #endif /* WINSTL_FORCE_UDATE || compiler */
  425. /* /////////////////////////////////////////////////////////////////////////
  426. * Contract Enforcement
  427. *
  428. * The macro winstl_assert provides standard debug-mode assert functionality.
  429. */
  430. /** \brief Defines an assertion construct for runtime verification.
  431. *
  432. * \param expr Must be non-zero, or an assertion will be fired
  433. *
  434. * \remarks By default this is defined to \ref STLSOFT_ASSERT. However, this
  435. * can be overriden if a prior definition is encountered, allowing the
  436. * runtime assertion of WinSTL components to use a different mechanism to
  437. * those in the other \ref group__projects "projects".
  438. */
  439. #ifndef WINSTL_ASSERT
  440. # define WINSTL_ASSERT(expr) STLSOFT_ASSERT(expr)
  441. #endif /* !WINSTL_ASSERT */
  442. /** \brief Defines a runtime assertion, with message
  443. *
  444. * \param expr Must be non-zero, or an assertion will be fired
  445. * \param msg The literal character string message to be included in the assertion
  446. */
  447. #define WINSTL_MESSAGE_ASSERT(msg, expr) STLSOFT_MESSAGE_ASSERT(msg, expr)
  448. /** \def WINSTL_STATIC_ASSERT(expr)
  449. *
  450. * \brief Defines an assertion construct for compile-time verification.
  451. *
  452. * \param expr A compile-time evaluatable condition that must be non-zero, or compilation will fail.
  453. *
  454. * \remarks This is defined to \ref STLSOFT_STATIC_ASSERT.
  455. */
  456. #define WINSTL_STATIC_ASSERT(expr) STLSOFT_STATIC_ASSERT(expr)
  457. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  458. # define winstl_assert(expr) WINSTL_ASSERT(expr)
  459. # define winstl_message_assert(msg, expr) WINSTL_MESSAGE_ASSERT(msg, expr)
  460. # define winstl_static_assert(expr) WINSTL_STATIC_ASSERT(expr)
  461. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  462. /* /////////////////////////////////////////////////////////////////////////
  463. * Namespace
  464. *
  465. * The WinSTL components are contained within the winstl namespace. This is
  466. * usually an alias for stlsoft::winstl_project,
  467. *
  468. * When compilers support namespaces they are defined by default. They can be
  469. * undefined using a cascasing system, as follows:
  470. *
  471. * If _STLSOFT_NO_NAMESPACES is defined, then _WINSTL_NO_NAMESPACES is defined.
  472. *
  473. * If _WINSTL_NO_NAMESPACES is defined, then _WINSTL_NO_NAMESPACE is defined.
  474. *
  475. * If _WINSTL_NO_NAMESPACE is defined, then the WinSTL constructs are defined
  476. * in the global scope.
  477. *
  478. * If _STLSOFT_NO_NAMESPACES, _WINSTL_NO_NAMESPACES and _WINSTL_NO_NAMESPACE are
  479. * all undefined but the symbol _STLSOFT_NO_NAMESPACE is defined (whence the
  480. * namespace stlsoft does not exist), then the WinSTL constructs are defined
  481. * within the winstl namespace. The definition matrix is as follows:
  482. *
  483. * _STLSOFT_NO_NAMESPACE _WINSTL_NO_NAMESPACE winstl definition
  484. * --------------------- -------------------- -----------------
  485. * not defined not defined = stlsoft::winstl_project
  486. * not defined defined not defined
  487. * defined not defined winstl
  488. * defined defined not defined
  489. *
  490. *
  491. *
  492. * The macro winstl_ns_qual() macro can be used to refer to elements in the
  493. * WinSTL libraries irrespective of whether they are in the
  494. * stlsoft::winstl_project (or winstl) namespace or in the global namespace.
  495. *
  496. * Furthermore, some compilers do not support the standard library in the std
  497. * namespace, so the winstl_ns_qual_std() macro can be used to refer to elements
  498. * in the WinSTL libraries irrespective of whether they are in the std namespace
  499. * or in the global namespace.
  500. */
  501. /* No STLSoft namespaces means no WinSTL namespaces */
  502. #ifdef _STLSOFT_NO_NAMESPACES
  503. # define _WINSTL_NO_NAMESPACES
  504. #endif /* _STLSOFT_NO_NAMESPACES */
  505. /* No WinSTL namespaces means no winstl namespace */
  506. #ifdef _WINSTL_NO_NAMESPACES
  507. # define _WINSTL_NO_NAMESPACE
  508. #endif /* _WINSTL_NO_NAMESPACES */
  509. #ifndef _WINSTL_NO_NAMESPACE
  510. # if defined(_STLSOFT_NO_NAMESPACE) || \
  511. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  512. /* There is no stlsoft namespace, so must define ::winstl */
  513. /** \brief The <code class="namespace">winstl</code> namespace contains all components
  514. * in the \ref group__project__winstl "WinSTL" project.
  515. *
  516. * By default, the <code>winstl</code> namespace is actually an alias for
  517. * the namespace <code>stlsoft::winstl_project</code>, which is where all
  518. * the \ref group__project__winstl "WinSTL" components actually reside. This
  519. * measure allows all components within the main the
  520. * \ref group__project__stlsoft "STLSoft" project (which are defined within
  521. * the <code>stlsoft</code> namespace) to be visible to all components
  522. * "within" the <code>winstl</code> namespace. (Otherwise, there would be a
  523. * whole lot of onerous qualification throughout the code of all
  524. * \ref group__projects "sub-projects".)
  525. *
  526. * \note If either/both of the symbols <code>_STLSOFT_NO_NAMESPACES</code>
  527. * and <code>_WINSTL_NO_NAMESPACE</code> are defined, all
  528. * \ref group__project__winstl "WinSTL" components will be defined in the
  529. * global namespace. Conversely, if the <code>_STLSOFT_NO_NAMESPACE</code>
  530. * symbol (not to be confused with the
  531. * <code>_STLSOFT_NO_NAMESPACES</code> symbol!) is defined - meaning that
  532. * all \ref group__project__stlsoft "main project" components are to be
  533. * defined in the global namespace, and <code>_WINSTL_NO_NAMESPACE</code>
  534. * is <b>not</b> defined, then all \ref group__project__winstl "WinSTL"
  535. * components will be defined within a bona fide <code>winstl</code>
  536. * namespace.
  537. *
  538. * \note This is a vestige of compatibility with compilers with
  539. * no (or no sensible) namespace support that is maintained for reasons of
  540. * backwards compatiblity and because it is, in <i>rare circumstances</i>, a
  541. * useful facility.
  542. */
  543. namespace winstl
  544. {
  545. # else
  546. /* Define stlsoft::winstl_project */
  547. namespace stlsoft
  548. {
  549. namespace winstl_project
  550. {
  551. # endif /* _STLSOFT_NO_NAMESPACE */
  552. #else
  553. stlsoft_ns_using(move_lhs_from_rhs)
  554. #endif /* !_WINSTL_NO_NAMESPACE */
  555. /** \def winstl_ns_qual(x)
  556. * \brief Namespace qualification macro for
  557. * \ref group__project__winstl "WinSTL" components that generates correct
  558. * code regardless of whether the <code>winstl</code> namespace is being
  559. * suppressed or enabled.
  560. *
  561. * If the <span class="code">winstl</span> namespace is being suppressed - by the
  562. * definition of <code>_WINSTL_NO_NAMESPACE</code> or
  563. * <code>_WINSTL_NO_NAMESPACES</code> or
  564. * <code>_STLSOFT_NO_NAMESPACES</code>; detectable by the presence of the
  565. * symbol <code>_WINSTL_NO_NAMESPACE</code> - then
  566. * <code>winstl_ns_using(x)</code> is equivalent to writing <code>x</code>.
  567. * If the <code>winstl</code> namespace is not being suppressed then
  568. * <code>winstl_ns_using(x)</code> is equivalent to writing <code>winstl::x</code>.
  569. *
  570. * For example, the following code will compile correctly if
  571. * <code>winstl</code> is suppressed or not:
  572. \code
  573. #include <winstl/error_desc.hpp>
  574. #include <stdio.h>
  575. int main()
  576. {
  577. winstl_ns_qual(reg_key) key(HKEY_CURRENT_USER, "SOFTWARE\\AcmeLib\\AcmeApp");
  578. return 0;
  579. }
  580. \endcode
  581. *
  582. * \remarks These macros are used throughout the <i>implementation</i> of the
  583. * STLSoft libraries. However, we do not recommend their use in application
  584. * code for the simple reason that they are ugly and do not represent a
  585. * widely recognised idiom. Of course, if they suit your purposes, then by
  586. * all means ...
  587. */
  588. /** \def winstl_ns_using(x)
  589. * \brief Declares a using directive (with respect to <b>winstl</b>) if WinSTL is using namespaces or, if not, does nothing
  590. */
  591. #ifndef _WINSTL_NO_NAMESPACE
  592. # define winstl_ns_qual(x) ::winstl::x
  593. # define winstl_ns_using(x) using ::winstl::x;
  594. #else
  595. # define winstl_ns_qual(x) x
  596. # define winstl_ns_using(x)
  597. #endif /* !_WINSTL_NO_NAMESPACE */
  598. /** \def winstl_ns_qual_std(x)
  599. * \brief Qualifies with <b>std::</b> if WinSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does not qualify.
  600. *
  601. * \see \ref page__namespace_suppression
  602. */
  603. /** \def winstl_ns_using_std(x)
  604. * Declares a using directive (with respect to <b>std</b>) if WinSTL is being translated in the context of the standard library being within the <b>std</b> namespace or, if not, does nothing.
  605. */
  606. #ifdef STLSOFT_CF_std_NAMESPACE
  607. # define winstl_ns_qual_std(x) ::std::x
  608. # define winstl_ns_using_std(x) using ::std::x;
  609. #else /* ? STLSOFT_CF_std_NAMESPACE */
  610. # define winstl_ns_qual_std(x) x
  611. # define winstl_ns_using_std(x)
  612. #endif /* !STLSOFT_CF_std_NAMESPACE */
  613. /* /////////////////////////////////////////////////////////////////////////
  614. * Language agnostic macros.
  615. */
  616. /** \def WINSTL_ITF_CALL(p)
  617. *
  618. * \ingroup group__project__comstl__language_agnostic_macros
  619. *
  620. * \brief Resolves to <b>p->lpVtbl</b> for C compilation, and to <b>p</b> in C++
  621. *
  622. * \see WINSTL_ITF_THIS, WINSTL_ITF_THIS0, WINSTL_IID_2_REF, WINSTL_REF_2_PTR
  623. */
  624. #if defined(__cplusplus)
  625. # define WINSTL_ITF_CALL(p) (p)
  626. #else /* ? __cplusplus */
  627. # define WINSTL_ITF_CALL(p) (p)->lpVtbl
  628. #endif /* __cplusplus */
  629. /** \def WINSTL_ITF_THIS(p)
  630. *
  631. * \ingroup group__project__comstl__language_agnostic_macros
  632. *
  633. * \brief Resolves to <b>p,</b> for C compilation, and to nothing in C++
  634. *
  635. * \see WINSTL_ITF_CALL, WINSTL_ITF_THIS0, WINSTL_IID_2_REF, WINSTL_REF_2_PTR
  636. */
  637. #if defined(__cplusplus)
  638. # define WINSTL_ITF_THIS(p)
  639. #else /* ? __cplusplus */
  640. # define WINSTL_ITF_THIS(p) (p),
  641. #endif /* __cplusplus */
  642. /** \def WINSTL_ITF_THIS0(p)
  643. *
  644. * \ingroup group__project__comstl__language_agnostic_macros
  645. *
  646. * \brief Resolves to <b>p</b> for C compilation, and to nothing in C++
  647. *
  648. * \see WINSTL_ITF_CALL, WINSTL_ITF_THIS, WINSTL_IID_2_REF, WINSTL_REF_2_PTR
  649. */
  650. #if defined(__cplusplus)
  651. # define WINSTL_ITF_THIS0(p)
  652. #else /* ? __cplusplus */
  653. # define WINSTL_ITF_THIS0(p) (p)
  654. #endif /* __cplusplus */
  655. /** \def WINSTL_IID_2_REF(iid)
  656. *
  657. * \ingroup group__project__comstl__language_agnostic_macros
  658. *
  659. * \brief Resolves to <b>&iid</b> for C compilation, and to <b>iid</b> in C++
  660. *
  661. * \see WINSTL_ITF_CALL, WINSTL_ITF_THIS, WINSTL_ITF_THIS0, WINSTL_REF_2_PTR
  662. */
  663. #if defined(__cplusplus)
  664. # define WINSTL_IID_2_REF(iid) (iid)
  665. #else /* ? __cplusplus */
  666. # define WINSTL_IID_2_REF(iid) (&(iid))
  667. #endif /* __cplusplus */
  668. /** \def WINSTL_REF_2_PTR(iid)
  669. *
  670. * \ingroup group__project__comstl__language_agnostic_macros
  671. *
  672. * \brief Resolves to <b>iid</b> for C compilation, and to <b>&iid</b> in C++
  673. *
  674. * \see WINSTL_ITF_CALL, WINSTL_ITF_THIS, WINSTL_ITF_THIS0, WINSTL_REF_2_REF
  675. */
  676. #if defined(__cplusplus)
  677. # define WINSTL_REF_2_PTR(iid) (&(iid))
  678. #else /* ? __cplusplus */
  679. # define WINSTL_REF_2_PTR(iid) (iid)
  680. #endif /* __cplusplus */
  681. /* /////////////////////////////////////////////////////////////////////////
  682. * Typedefs
  683. *
  684. * The WinSTL uses a number of typedefs to aid in compiler-independence in the
  685. * libraries' main code.
  686. */
  687. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  688. typedef stlsoft_ns_qual(ss_char_a_t) ws_char_a_t; /**!< Ansi char type. */
  689. typedef stlsoft_ns_qual(ss_char_w_t) ws_char_w_t; /**!< Unicode char type. */
  690. typedef stlsoft_ns_qual(ss_sint8_t) ws_sint8_t; /**!< 8-bit signed integer. */
  691. typedef stlsoft_ns_qual(ss_uint8_t) ws_uint8_t; /**!< 8-bit unsigned integer. */
  692. typedef stlsoft_ns_qual(ss_int16_t) ws_int16_t; /**!< 16-bit integer. */
  693. typedef stlsoft_ns_qual(ss_sint16_t) ws_sint16_t; /**!< 16-bit signed integer. */
  694. typedef stlsoft_ns_qual(ss_uint16_t) ws_uint16_t; /**!< 16-bit unsigned integer. */
  695. typedef stlsoft_ns_qual(ss_int32_t) ws_int32_t; /**!< 32-bit integer. */
  696. typedef stlsoft_ns_qual(ss_sint32_t) ws_sint32_t; /**!< 32-bit signed integer. */
  697. typedef stlsoft_ns_qual(ss_uint32_t) ws_uint32_t; /**!< 32-bit unsigned integer. */
  698. #ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  699. typedef stlsoft_ns_qual(ss_int64_t) ws_int64_t; /**!< 64-bit integer. */
  700. typedef stlsoft_ns_qual(ss_sint64_t) ws_sint64_t; /**!< 64-bit signed integer. */
  701. typedef stlsoft_ns_qual(ss_uint64_t) ws_uint64_t; /**!< 64-bit unsigned integer. */
  702. #endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  703. # ifdef _WIN64
  704. typedef LONG_PTR ws_intptr_t; /**!< integer capable of holding pointer without loss */
  705. typedef LONG_PTR ws_sintptr_t; /**!< signed integer capable of holding pointer without loss */
  706. typedef ULONG_PTR ws_uintptr_t; /**!< unsigned integer capable of holding pointer without loss */
  707. # else /* ? _WIN64 */
  708. typedef LONG ws_intptr_t; /**!< integer capable of holding pointer without loss */
  709. typedef LONG ws_sintptr_t; /**!< signed integer capable of holding pointer without loss */
  710. typedef ULONG ws_uintptr_t; /**!< unsigned integer capable of holding pointer without loss */
  711. # endif /* _WIN64 */
  712. typedef stlsoft_ns_qual(ss_int_t) ws_int_t; /**!< integer. */
  713. typedef stlsoft_ns_qual(ss_sint_t) ws_sint_t; /**!< signed integer. */
  714. typedef stlsoft_ns_qual(ss_uint_t) ws_uint_t; /**!< unsigned integer. */
  715. typedef stlsoft_ns_qual(ss_long_t) ws_long_t; /**!< long. */
  716. typedef stlsoft_ns_qual(ss_byte_t) ws_byte_t; /**!< Byte. */
  717. #if defined(__cplusplus)
  718. typedef stlsoft_ns_qual(ss_bool_t) ws_bool_t; /**!< bool. */
  719. #endif /* __cplusplus */
  720. typedef DWORD ws_dword_t; /**!< dword. */
  721. typedef stlsoft_ns_qual(ss_size_t) ws_size_t; /**!< size. */
  722. typedef stlsoft_ns_qual(ss_ptrdiff_t) ws_ptrdiff_t; /**!< ptr diff. */
  723. typedef stlsoft_ns_qual(ss_streampos_t) ws_streampos_t; /**!< streampos. */
  724. typedef stlsoft_ns_qual(ss_streamoff_t) ws_streamoff_t; /**!< streamoff. */
  725. #ifdef WINSTL_OS_IS_WIN64
  726. typedef stlsoft_ns_qual(ss_sint64_t) ws_sptrint_t;
  727. typedef stlsoft_ns_qual(ss_uint64_t) ws_uptrint_t;
  728. #else /* ? WINSTL_OS_IS_WIN64 */
  729. typedef stlsoft_ns_qual(ss_sint32_t) ws_sptrint_t;
  730. typedef stlsoft_ns_qual(ss_uint32_t) ws_uptrint_t;
  731. #endif /* WINSTL_OS_IS_WIN64 */
  732. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  733. #ifndef _WINSTL_NO_NAMESPACE
  734. typedef ws_char_a_t char_a_t; /**!< Ansi char type. */
  735. typedef ws_char_w_t char_w_t; /**!< Unicode char type. */
  736. /* typedef ws_int8_t int8_t; */ /**!< 8-bit integer. */
  737. typedef ws_sint8_t sint8_t; /**!< 8-bit signed integer. */
  738. typedef ws_uint8_t uint8_t; /**!< 8-bit unsigned integer. */
  739. typedef ws_int16_t int16_t; /**!< 16-bit integer. */
  740. typedef ws_sint16_t sint16_t; /**!< 16-bit signed integer. */
  741. typedef ws_uint16_t uint16_t; /**!< 16-bit unsigned integer. */
  742. typedef ws_int32_t int32_t; /**!< 32-bit integer. */
  743. typedef ws_sint32_t sint32_t; /**!< 32-bit signed integer. */
  744. typedef ws_uint32_t uint32_t; /**!< 32-bit unsigned integer. */
  745. # ifdef STLSOFT_CF_64BIT_INT_SUPPORT
  746. typedef ws_int64_t int64_t; /**!< 64-bit integer. */
  747. typedef ws_sint64_t sint64_t; /**!< 64-bit signed integer. */
  748. typedef ws_uint64_t uint64_t; /**!< 64-bit unsigned integer. */
  749. # endif /* STLSOFT_CF_64BIT_INT_SUPPORT */
  750. /* typedef ws_short_t short_t; */ /**!< short integer. */
  751. typedef ws_int_t int_t; /**!< integer. */
  752. typedef ws_sint_t sint_t; /**!< signed integer. */
  753. typedef ws_uint_t uint_t; /**!< unsigned integer. */
  754. typedef ws_long_t long_t; /**!< long integer. */
  755. typedef ws_byte_t byte_t; /**!< Byte. */
  756. #if defined(__cplusplus)
  757. typedef ws_bool_t bool_t; /**!< bool. */
  758. #endif /* __cplusplus */
  759. typedef ws_dword_t dword_t; /**!< dword. */
  760. # if !defined(STLSOFT_COMPILER_IS_DMC)
  761. typedef ws_streampos_t streampos_t; /**!< streampos. */
  762. typedef ws_streamoff_t streamoff_t; /**!< streamoff. */
  763. # endif /* compiler */
  764. typedef ws_sptrint_t sptrint_t;
  765. typedef ws_uptrint_t uptrint_t;
  766. #endif /* !_WINSTL_NO_NAMESPACE */
  767. /* /////////////////////////////////////////////////////////////////////////
  768. * Constants
  769. */
  770. /** \def WINSTL_CONST_NT_MAX_PATH
  771. *
  772. * \brief Defines the number of maximum length of a path specification on
  773. * Windows NT: 4 + 32767.
  774. *
  775. * Windows NT supports so-called "long names" in the Unicode variants (e.g.
  776. * <code>CreateFileW()</code>) of many of its file-system API functions. The
  777. * maximum length of a long name is 32767, and a long name must be prefixed
  778. * with the 4-character sequence <code>\\\\\?\\</code>. This constant can be
  779. * used when there is a need to allocate the maximum possible size for a
  780. * file system path.
  781. */
  782. #define WINSTL_CONST_NT_MAX_PATH (4 + 32767)
  783. /** \def WINSTL_CONST_MAX_PATH
  784. *
  785. */
  786. #if defined(_MAX_PATH)
  787. # define WINSTL_CONST_MAX_PATH _MAX_PATH
  788. #elif defined(__CYGWIN__)
  789. # define WINSTL_CONST_MAX_PATH (260)
  790. #else
  791. # error _MAX_PATH not defined, and not CygWin compiler
  792. #endif
  793. #ifdef __cplusplus
  794. /** \brief C++ constant equivalent to \ref WINSTL_CONST_NT_MAX_PATH.
  795. */
  796. const ws_size_t CONST_NT_MAX_PATH = WINSTL_CONST_NT_MAX_PATH;
  797. /** \brief C++ constant equivalent to \ref WINSTL_CONST_MAX_PATH.
  798. */
  799. const ws_size_t CONST_MAX_PATH = WINSTL_CONST_MAX_PATH;
  800. #endif /* __cplusplus */
  801. /* /////////////////////////////////////////////////////////////////////////
  802. * Values
  803. *
  804. * Since the boolean type may not be supported natively on all compilers, the
  805. * values of true and false may also not be provided. Hence the values of
  806. * ws_true_v and ws_false_v are defined, and are used in all code.
  807. */
  808. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  809. #define ws_true_v ss_true_v
  810. #define ws_false_v ss_false_v
  811. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  812. /* /////////////////////////////////////////////////////////////////////////
  813. * Code modification macros
  814. */
  815. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  816. /* Exception signatures. */
  817. # define winstl_throw_0() stlsoft_throw_0()
  818. # define winstl_throw_1(x1) stlsoft_throw_1(x1)
  819. # define winstl_throw_2(x1, x2) stlsoft_throw_2(x1, x2)
  820. # define winstl_throw_3(x1, x2, x3) stlsoft_throw_3(x1, x2, x3)
  821. # define winstl_throw_4(x1, x2, x3, x4) stlsoft_throw_4(x1, x2, x3, x4)
  822. # define winstl_throw_5(x1, x2, x3, x4, x5) stlsoft_throw_5(x1, x2, x3, x4, x5)
  823. # define winstl_throw_6(x1, x2, x3, x4, x5, x6) stlsoft_throw_6(x1, x2, x3, x4, x5, x6)
  824. # define winstl_throw_7(x1, x2, x3, x4, x5, x6, x7) stlsoft_throw_7(x1, x2, x3, x4, x5, x6, x7)
  825. # define winstl_throw_8(x1, x2, x3, x4, x5, x6, x7, x8) stlsoft_throw_8(x1, x2, x3, x4, x5, x6, x7, x8)
  826. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  827. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  828. # define WINSTL_NUM_ELEMENTS(ar) STLSOFT_NUM_ELEMENTS(ar)
  829. # define winstl_num_elements(ar) WINSTL_NUM_ELEMENTS(ar)
  830. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  831. /** \brief [DEPRECATED] Destroys the given instance \c p of the given type (\c t and \c _type)
  832. *
  833. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_DESTROY_INSTANCE().
  834. */
  835. #define winstl_destroy_instance(t, _type, p) STLSOFT_DESTROY_INSTANCE(t, _type, p)
  836. /** \brief [DEPRECATED] Generates an opaque type with the name \c _htype
  837. *
  838. * \deprecated This is <b>heavily</b> deprecated in favour of \ref STLSOFT_GEN_OPAQUE().
  839. */
  840. #define winstl_gen_opaque(_htype) STLSOFT_GEN_OPAQUE(_htype)
  841. /* /////////////////////////////////////////////////////////////////////////
  842. * Macros
  843. */
  844. #ifdef __cplusplus
  845. /** \brief Safely converts a <code>BOOL</code> to a <code>bool</code>.
  846. *
  847. * \param bVal The instance of <code>BOOL</code> to be converted to <code>bool</code>.
  848. *
  849. * \retval false If <code>bVal</code> is 0.
  850. * \retval true If <code>bVal</code> is non-0.
  851. *
  852. * \note In C compilation, this is defined as a functionally equivalent macro.
  853. *
  854. * \remark Because all compilers (that we know about) represent a
  855. * <code>bool</code> as one byte and <code>BOOL</code> (which is a typedef
  856. * from <code>int</code>) as more than one byte, safely converting from
  857. * <code>BOOL</code> to <code>bool</code> has to involve a runtime test
  858. * against 0 that cannot be inlined by the compiler. Consequently, use of
  859. * BOOL2bool() should be avoided where possible, and extensive use of it
  860. * in your code base likely represents misuse. (<b>See</b> section 13.4.2
  861. * of <a href = "http://www.imperfectcplusplus.com/" target="blank">Imperfect C++</a>
  862. * for a discussion of these issues.)
  863. */
  864. #ifdef _Wp64
  865. inline bool BOOL2bool(ws_int_t bVal)
  866. #else /* ? _Wp64 */
  867. inline bool BOOL2bool(BOOL bVal)
  868. #endif /* _Wp64 */
  869. {
  870. return bVal != FALSE;
  871. }
  872. /** \brief Safely converts a <code>bool</code> to a <code>BOOL</code>.
  873. *
  874. * \param bVal The instance of <code>bool</code> to be converted to <code>BOOL</code>.
  875. *
  876. * \retval 0 If <code>bVal</code> is <code>false</code>.
  877. * \retval 1 If <code>bVal</code> is <code>true</code>.
  878. *
  879. * \note In C compilation, this is defined as a functionally equivalent macro.
  880. *
  881. * \remark Although use of the <code>BOOL</code> type indicates that a
  882. * <b>"false"</b> condition is represented by a value of 0, and all other values
  883. * represent <b>"true"</b> it is not the case that all client code is implemented
  884. * as such. In order to avoid fruitless debates with users of STLSoft who
  885. * may be unaware of this convention, or unwilling or unable to accept it,
  886. * bool2BOOL() implemented to ensure that the return value is only ever 0 or 1.
  887. * Consequently, use of this function should be avoided where possible, and
  888. * extensive use of it in your code base likely represents misuse.
  889. * (<b>See</b> section 13.4.2 of
  890. * <a href = "http://www.imperfectcplusplus.com/" target="blank">Imperfect C++</a>
  891. * for a discussion of these issues.)
  892. */
  893. inline BOOL bool2BOOL(bool bVal)
  894. {
  895. return bVal != false;
  896. }
  897. #else
  898. # define BOOL2bool(bVal) stlsoft_static_cast(bool, ((bVal) != FALSE))
  899. # define bool2BOOL(bVal) stlsoft_static_cast(BOOL, ((bVal) != false))
  900. #endif /* __cplusplus */
  901. /* /////////////////////////////////////////////////////////////////////////
  902. * Namespace
  903. */
  904. #ifndef _WINSTL_NO_NAMESPACE
  905. # if defined(_STLSOFT_NO_NAMESPACE) || \
  906. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  907. } /* namespace winstl */
  908. # else
  909. } /* namespace winstl_project */
  910. } /* namespace stlsoft */
  911. namespace winstl = ::stlsoft::winstl_project;
  912. # endif /* _STLSOFT_NO_NAMESPACE */
  913. #endif /* !_WINSTL_NO_NAMESPACE */
  914. /* /////////////////////////////////////////////////////////////////////////
  915. * Inclusion
  916. */
  917. #ifdef STLSOFT_CF_PRAGMA_ONCE_SUPPORT
  918. # pragma once
  919. #endif /* STLSOFT_CF_PRAGMA_ONCE_SUPPORT */
  920. /* ////////////////////////////////////////////////////////////////////// */
  921. #endif /* WINSTL_INCL_WINSTL_H_WINSTL */
  922. /* ///////////////////////////// end of file //////////////////////////// */