_evc.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /*
  2. * File to have Microsoft eMbedded Visual C++ 3.0 and .NET working with STLport
  3. * May 2004
  4. * Origin : Zdenek Nemec - zero@mapfactor.com
  5. * Michael Fink - vividos@users.sourceforge.net
  6. */
  7. #ifndef _STLP_EVC_H
  8. #define _STLP_EVC_H
  9. #define _STLP_COMPILER "eMbedded Visual C++"
  10. // This flag is being used by STLport to support
  11. // old-fashioned Windows CE SDK (see stl_wince.h)
  12. // do not use with eMebedded Visual C++ 3 or 4!
  13. #ifdef _STLP_WINCE
  14. # undef _STLP_WINCE
  15. #endif
  16. /* Compiler dependent define. The following defines may be available:
  17. * _STLP_WCE_EVC3 when compiling under eMbedded Visual C++ 3
  18. * _STLP_WCE_NET when compiling under eMbedded Visual C++ .NET
  19. * _STLP_WCE always defined when compiling with one of the above
  20. */
  21. #undef _STLP_WCE_EVC3
  22. #undef _STLP_WCE_NET
  23. #if (_WIN32_WCE > 300)
  24. # define _STLP_WCE_NET UNDER_CE
  25. #elif (_WIN32_WCE == 300)
  26. # define _STLP_WCE_EVC3 UNDER_CE
  27. #else
  28. # error No support for Windows CE below 3.0!
  29. #endif
  30. // This is defined for all platforms using Windows CE
  31. #define _STLP_WCE
  32. /* All Windows CE versions up to at least version 5 are little-endian, even
  33. * if the hardware (like e.g. MIPS) can be configured for big-endian, too. */
  34. #define _STLP_LITTLE_ENDIAN
  35. // Ensure _DEBUG is defined.
  36. #if defined (DEBUG) && !defined (_DEBUG)
  37. # define _DEBUG
  38. #endif
  39. // inherit all msvc6 options
  40. #include <stl/config/_msvc.h>
  41. // CE up to at least version 5 has no C locale support
  42. #define _STLP_NO_LOCALE_SUPPORT
  43. #if _WIN32_WCE >= 420
  44. // SDKs built with PB5 have terminate&co in namespace std...
  45. # define _STLP_VENDOR_TERMINATE_STD _STLP_VENDOR_STD
  46. # define _STLP_VENDOR_UNCAUGHT_EXCEPTION_STD _STLP_VENDOR_STD
  47. // ...and new_handler/set_new_handler in the global namespace.
  48. # define _STLP_GLOBAL_NEW_HANDLER 1
  49. #endif
  50. // Always threaded in eMbedded Visual C++ 3.0 and .NET
  51. #ifndef _MT
  52. # define _MT
  53. #endif
  54. // we don't have a static native runtime library
  55. #undef _STLP_USING_CROSS_NATIVE_RUNTIME_LIB
  56. #if _WIN32_WCE < 400
  57. // no long double under CE3 and older
  58. # define _STLP_NO_LONG_DOUBLE
  59. #endif
  60. // no *f and *l math functions available
  61. #define _STLP_NO_VENDOR_MATH_F
  62. #define _STLP_NO_VENDOR_MATH_L
  63. /*
  64. * Redirect cout, cerr and clog:
  65. * If defined redirect cout, cerr and clog to
  66. * files stdout.txt, stderr.txt and stdlog.txt
  67. */
  68. //# define _STLP_REDIRECT_STDSTREAMS
  69. /*
  70. * Static class members may generate LNK1179:
  71. * Wrong COMDAT packing may cause LNK1179 error.
  72. * For details see http://groups.google.com/groups?th=8a05c82c4ffee280
  73. * example P78. This define is not used/needed at this moment
  74. * but may came handy in future...
  75. */
  76. //# define _STLP_STATIC_MEMBERS_BUG
  77. // Use wide-string interface of windows native functions (CreateFile...).
  78. // Note that this should be defined all the time while under CE.
  79. #if defined (UNICODE)
  80. # define _STLP_USE_WIDE_INTERFACE
  81. #endif
  82. // Force exception std to std instead of __std_alias.
  83. #if defined (__cplusplus) && !defined (_STLP_HAS_NO_NAMESPACES)
  84. # ifdef _STLP_VENDOR_EXCEPT_STD
  85. # undef _STLP_VENDOR_EXCEPT_STD
  86. # endif
  87. # define _STLP_VENDOR_EXCEPT_STD std
  88. #endif
  89. // short string optimization bug under evc3, evc4 using ARM compiler
  90. #if _MSC_VER < 1400 && (defined (ARM) || defined (_ARM_))
  91. # define _STLP_DONT_USE_SHORT_STRING_OPTIM
  92. #endif
  93. // when using MFC, disable another placement new declaration, since there is one in wcealt.h
  94. #if !defined (__BUILDING_STLPORT) && defined (_MFC_VER)
  95. # define __PLACEMENT_NEW_INLINE
  96. #endif
  97. // threads
  98. #undef _REENTRANT
  99. #define _REENTRANT
  100. #undef _NOTHREADS
  101. // Use old fashioned headers (ctime vs. time.h).
  102. #undef _STLP_NO_NEW_C_HEADERS
  103. #define _STLP_NO_NEW_C_HEADERS
  104. // exception handling support: only on evc4 and user added /GX to project settings
  105. #if defined (_STLP_WCE_EVC3) || !defined (_CPPUNWIND)
  106. # define _STLP_NO_EXCEPTION_HEADER
  107. # define _STLP_NO_EXCEPTIONS
  108. # undef _STLP_USE_EXCEPTIONS
  109. # ifndef _STLP_THROW_BAD_ALLOC
  110. # define _STLP_THROW_BAD_ALLOC { _STLP_WINCE_TRACE(L"out of memory"); ExitThread(1); }
  111. # endif
  112. #endif
  113. #define _STLP_WINCE_TRACE(msg) OutputDebugString(msg)
  114. /*
  115. * eMbedded Visual C++ .NET specific settings
  116. */
  117. #if defined (_STLP_WCE_NET)
  118. // evc4 has no locale and time support
  119. # define _STLP_NO_LOCALE_SUPPORT
  120. # define _STLP_NO_TIME_SUPPORT
  121. // ptrdiff_t is not defined in evc4 headers
  122. # ifndef _PTRDIFF_T_DEFINED
  123. typedef int ptrdiff_t;
  124. # define _PTRDIFF_T_DEFINED
  125. # endif
  126. /*
  127. * Helper macros for including the native headers in cases where a file with
  128. * the same name also exists in the STLport include folder. The idea behind
  129. * this is that we first go up one directory and then down into a dir that
  130. * is only present in the native install but not in STLport.
  131. *
  132. */
  133. # if !defined (_STLP_NATIVE_INCLUDE_PATH)
  134. # if defined (_X86_)
  135. # if defined (_STLP_WCE_TARGET_PROC_SUBTYPE_EMULATOR)
  136. # define _STLP_NATIVE_INCLUDE_PATH ../Emulator
  137. # else
  138. # define _STLP_NATIVE_INCLUDE_PATH ../X86
  139. # endif
  140. # elif defined (_ARM_)
  141. # if _MSC_VER < 1400
  142. // eVC3/4
  143. # if defined (ARMV4)
  144. # define _STLP_NATIVE_INCLUDE_PATH ../Armv4
  145. # elif defined (ARMV4I)
  146. # define _STLP_NATIVE_INCLUDE_PATH ../Armv4i
  147. # elif defined (ARMV4T)
  148. # define _STLP_NATIVE_INCLUDE_PATH ../Armv4t
  149. # else
  150. # error Unknown ARM SDK.
  151. # endif
  152. # else
  153. // VC8 crosscompiling for CE
  154. # if defined (ARMV4)
  155. // VC8 bundled Pocket PC 2003 SDK don't have a target CPU subfolder.
  156. # if defined(WIN32_PLATFORM_PSPC)
  157. # define _STLP_NATIVE_INCLUDE_PATH ../Include
  158. # else
  159. # define _STLP_NATIVE_INCLUDE_PATH ../Armv4
  160. # endif
  161. # elif defined(ARMV4I) || defined(ARMV4T)
  162. # define _STLP_NATIVE_INCLUDE_PATH ../Armv4i
  163. # else
  164. # error Unknown ARM SDK.
  165. # endif
  166. # endif
  167. # elif defined (_MIPS_)
  168. # if defined (MIPS16)
  169. # define _STLP_NATIVE_INCLUDE_PATH ../mips16
  170. # elif defined (MIPSII)
  171. # define _STLP_NATIVE_INCLUDE_PATH ../mipsII
  172. # elif defined (MIPSII_FP)
  173. # define _STLP_NATIVE_INCLUDE_PATH ../mipsII_fp
  174. # elif defined (MIPSIV)
  175. # define _STLP_NATIVE_INCLUDE_PATH ../mipsIV
  176. # elif defined (MIPSIV_FP)
  177. # define _STLP_NATIVE_INCLUDE_PATH ../mipsIV_fp
  178. # else
  179. # error Unknown MIPS SDK.
  180. # endif
  181. # elif defined (SHx)
  182. # if defined (SH3)
  183. # define _STLP_NATIVE_INCLUDE_PATH ../sh3
  184. # elif defined (SH4)
  185. # define _STLP_NATIVE_INCLUDE_PATH ../sh4
  186. # else
  187. # error Unknown SHx SDK.
  188. # endif
  189. # else
  190. # error Unknown SDK.
  191. # endif
  192. # endif /* !_STLP_NATIVE_INCLUDE_PATH */
  193. /* Workaround when using MFCCE and using <new> together: MFCCE's wcealt.h doesn't
  194. * check for __PLACEMENT_NEW_INLINE before defining operator new, so when <new>
  195. * defines the operatore before, there will be an error C2084:
  196. * "function 'void *__cdecl operator new(unsigned int,void *)' already has a body".
  197. */
  198. # ifdef _STLP_USE_MFC
  199. # define __PLACEMENT_NEW_INLINE
  200. # endif
  201. #endif /* _STLP_WCE_NET */
  202. /*
  203. * eMbedded Visual C++ 3.0 specific settings
  204. */
  205. #if defined (_STLP_WCE_EVC3)
  206. # define _STLP_NO_NATIVE_MBSTATE_T
  207. // evc3 has no locale and time support
  208. # define _STLP_NO_LOCALE_SUPPORT
  209. # define _STLP_NO_TIME_SUPPORT
  210. // evc3 has new, but no explicit header
  211. # define _STLP_NO_NEW_HEADER
  212. # define _STLP_NO_NEW_NEW_HEADER
  213. // evc3 has no bad_alloc and no typeinfo
  214. # undef _STLP_NO_BAD_ALLOC
  215. # define _STLP_NO_BAD_ALLOC
  216. # undef _STLP_NO_TYPEINFO
  217. # define _STLP_NO_TYPEINFO
  218. // missing things in eMbedded Visual C++ 3.0 headers
  219. # ifndef _SIZE_T_DEFINED
  220. typedef unsigned int size_t;
  221. # define _SIZE_T_DEFINED
  222. # endif
  223. # ifndef _WCHAR_T_DEFINED
  224. typedef unsigned short wchar_t;
  225. # define _WCHAR_T_DEFINED
  226. # endif
  227. // ptrdiff_t is not defined in evc3 headers
  228. # ifndef _PTRDIFF_T_DEFINED
  229. typedef int ptrdiff_t;
  230. # define _PTRDIFF_T_DEFINED
  231. # endif
  232. // clock_t is not defined in evc3 headers
  233. # ifndef _CLOCK_T_DEFINED
  234. typedef long clock_t;
  235. # define _CLOCK_T_DEFINED
  236. # endif
  237. // Struct tm is not defined in evc3 headers
  238. # ifndef _TM_DEFINED
  239. struct tm {
  240. int tm_sec; /* seconds after the minute - [0,59] */
  241. int tm_min; /* minutes after the hour - [0,59] */
  242. int tm_hour; /* hours since midnight - [0,23] */
  243. int tm_mday; /* day of the month - [1,31] */
  244. int tm_mon; /* months since January - [0,11] */
  245. int tm_year; /* years since 1900 */
  246. int tm_wday; /* days since Sunday - [0,6] */
  247. int tm_yday; /* days since January 1 - [0,365] */
  248. int tm_isdst; /* daylight savings time flag */
  249. };
  250. # define _TM_DEFINED
  251. # endif
  252. // define placement new and delete operator
  253. // note: when MFCCE headers are included first, don't define the new operator,
  254. // since it was already defined in wcealt.h
  255. # ifdef __cplusplus
  256. # ifndef __PLACEMENT_NEW_INLINE
  257. # ifndef _MFC_VER
  258. inline void *__cdecl operator new(size_t, void *_P) { return (_P); }
  259. # endif /* _MFC_VER */
  260. inline void __cdecl operator delete(void *, void *) { return; }
  261. # define __PLACEMENT_NEW_INLINE
  262. # endif
  263. # endif /* __cplusplus */
  264. // evc3 doesn't have native wide functions, e.g. fgetwc, wmemmove
  265. # define _STLP_NO_NATIVE_WIDE_FUNCTIONS
  266. // evc3 doesn't have assert.h
  267. # ifndef _ASSERT_DEFINED
  268. # define assert(expr) _STLP_ASSERT(expr)
  269. # define _ASSERT_DEFINED
  270. # endif
  271. #endif /* _STLP_WCE_EVC3 */
  272. /*
  273. * original call: TerminateProcess(GetCurrentProcess(), 0);
  274. * we substitute the GetCurrentProcess() with the result of the inline function
  275. * defined in kfuncs.h, since we then can avoid including <windows.h> at all.
  276. * all needed Win32 API functions are defined in <stl/_windows.h>
  277. */
  278. #ifndef _ABORT_DEFINED
  279. # define _STLP_ABORT() TerminateProcess(reinterpret_cast<HANDLE>(66), 0)
  280. # define _ABORT_DEFINED
  281. #endif
  282. // Notice: windows.h isn't included here anymore; all needed defines are in
  283. // stl/_windows.h now
  284. #endif /* _STLP_EVC_H */