OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
defs.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1993, 1996 by Borland International, All Rights Reserved
4//
5//----------------------------------------------------------------------------
6
7#if !defined(OWL_PRIVATE_DEFS_H)
8#define OWL_PRIVATE_DEFS_H
9#define OSL_DEFS_H
10#define SERVICES_DEFS_H
11#define WINSYS_DEFS_H
12
13#if !defined(__cplusplus)
14#error OWLNext requires C++ compilation.
15#endif
16
17#if !defined(_WIN32)
18# error OWLNext requires _WIN32 (_WIN16 is no longer supported).
19#endif
20
21//
22// Define the type of application being built. Must be one of:
23//
24// BI_APP_EXECUTABLE
25// BI_APP_DLL
26//
27#if defined(__DLL__) || defined(_DLL) || defined(_WINDLL)
28# define BI_APP_DLL
29#else
30# define BI_APP_EXECUTABLE
31#endif
32
33//
34// Only enable multi-thread classes when the OS supports them, and/or when the
35// runtime library support them
36//
37// BI_MULTI_THREAD
38// BI_MULTI_THREAD_RTL
39//
40// Specific name of compiler, BI_COMP_xxxx
41//
42// BI_COMP_BORLANDC or BI_COMP_MSC or BI_COMP_GNU
43//
44// BI_NO_LVAL_CASTS // Can cast lvalues
45//
46// _WIN32
47//
48// OWL_BREAK -> debug trap instruction
49//
50//
51// BI_NOTHUNK -> don't use thunks (WARNING! Not safe! Deprecated.)
52//
53// Include the appropriate compiler-specific header based on known compiler
54// defined preprocessor constants
55//
56// BI_VIRTUAL_BUG -> virtual bug with micro$oft, no bug but different
57// handling of C++ ???
58// BI_OWL_PACKING -> aligment if not defined default 1
59// BI_TYPECASTOPERATOR_BUG -> if problem with type cast operator like: operator HWND()
60// BI_GLOBALNM_BUG -> Global namespace bug in MSVC like mfunc(int name = ::someName);
61// BI_NOTEMPLATE_H -> No include <owl/template.h> -> not defined
62// BI_HAS_PRAGMA_ONCE -> support for pragma once
63//----------------------------------------------------------------------------
64// We must use all libraries in DLLs if we are using Owl in a DLL
65//
66// Define _OWLDLL with -WSE (-WE for 32bit) to use Owl, bids & RTL in dlls.
67//
68// Be sure _BUILDOWLDLL is defined when building an actual owl dll
69//
70
71//JJH use only if not using msvcrt's stdlib.h
72#if defined(BI_NEED_PRIVATE_OWLPORT) //for Syncad boys, probably should be obsolote right now.
73#include <port/owl-port.h>
74#endif
75
76#if defined(_OWLDLL) || defined(_BUILDOWLDLL)
77# if !defined(_OWLDLL)
78# define _OWLDLL
79# endif
80
81# if !defined(_RTLDLL)
82# define _RTLDLL
83# endif
84#endif
85
86#if defined(_DEBUG)
87#if !defined(__DEBUG)
88# define __DEBUG 1
89#endif
90#endif
91
92#if defined(__DEBUG) && __DEBUG > 0
93# if !defined(_DEBUG)
94# define _DEBUG
95# endif
96#endif
97
98#if defined(UNICODE)
99# if !defined(_UNICODE)
100# define _UNICODE
101# endif
102#endif
103
104#if defined(_UNICODE)
105# if !defined(UNICODE)
106# define UNICODE
107# endif
108#endif
109
110#if !defined(OWL_STACKWALKER)
111# define OWL_STACKWALKER 0
112#else
113# if OWL_STACKWALKER && !(defined(_MSC_VER) && __DEBUG)
114# error OWL_STACKWALKER is only supported in debug mode for the Microsoft compiler.
115# endif
116#endif
117
118
119#if defined(_MSC_VER)
120 #define OWL_DISABLE_WARNING_PUSH __pragma(warning( push ))
121 #define OWL_DISABLE_WARNING_POP __pragma(warning( pop ))
122 #define OWL_DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))
123
124 #define OWL_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER OWL_DISABLE_WARNING(4100)
125 #define OWL_DISABLE_WARNING_UNREFERENCED_FUNCTION OWL_DISABLE_WARNING(4505)
126
127 // TODO:
128 #define OWL_DISABLE_WARNING_EXTENSION
129 #define OWL_DISABLE_WARNING_ZERO_AS_NULL_POINTER
130 #define OWL_DISABLE_WARNING_OLD_STYLE_CAST
131 // other warnings you want to deactivate...
132
133#elif defined(__clang__) || defined(__GNUC__)
134 #define OWL_DO_PRAGMA_(X) _Pragma(#X)
135
136 #if defined(__clang__)
137 #define OWL_DISABLE_WARNING_PUSH OWL_DO_PRAGMA_(clang diagnostic push)
138 #define OWL_DISABLE_WARNING_POP OWL_DO_PRAGMA_(clang diagnostic pop)
139 #define OWL_DISABLE_WARNING(warningName) OWL_DO_PRAGMA_(clang diagnostic ignored #warningName)
140 #elif defined(__GNUC__)
141 #define OWL_DISABLE_WARNING_PUSH OWL_DO_PRAGMA_(GCC diagnostic push)
142 #define OWL_DISABLE_WARNING_POP OWL_DO_PRAGMA_(GCC diagnostic pop)
143 #define OWL_DISABLE_WARNING(warningName) OWL_DO_PRAGMA_(GCC diagnostic ignored #warningName)
144 #endif
145
146 #define OWL_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER OWL_DISABLE_WARNING(-Wunused-parameter)
147 #define OWL_DISABLE_WARNING_UNREFERENCED_FUNCTION OWL_DISABLE_WARNING(-Wunused-function)
148 #define OWL_DISABLE_WARNING_EXTENSION OWL_DISABLE_WARNING(-Wlanguage-extension-token)
149 #define OWL_DISABLE_WARNING_ZERO_AS_NULL_POINTER OWL_DISABLE_WARNING(-Wzero-as-null-pointer-constant)
150 #define OWL_DISABLE_WARNING_OLD_STYLE_CAST OWL_DISABLE_WARNING(-Wold-style-cast)
151
152 // other warnings you want to deactivate...
153
154#else
155 #define OWL_DISABLE_WARNING_PUSH
156 #define OWL_DISABLE_WARNING_POP
157 #define OWL_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
158 #define OWL_DISABLE_WARNING_UNREFERENCED_FUNCTION
159 #define OWL_DISABLE_WARNING_EXTENSION
160 #define OWL_DISABLE_WARNING_ZERO_AS_NULL_POINTER
161 #define OWL_DISABLE_WARNING_OLD_STYLE_CAST
162 // other warnings you want to deactivate...
163
164#endif
165
166#if defined(__BORLANDC__)
167# include <owl/private/borlandc.h>
168#elif defined(_MSC_VER)
169# include <owl/private/msc.h>
170#elif defined(__GNUC__)
171# include <owl/private/gnuc.h>
172#elif defined(__WATCOMC__)
173# error Watcom currently not supported
174#elif defined(__FORTE__)
175# error Forte currently not supported
176#else
177#error Unknown compiler
178#endif
179
180//----------------------------------------------------------------------------
181//
182// Defines macro to force a debug trap.
183//
184#if !defined(OWL_BREAK)
185# include <assert.h>
186# define OWL_BREAK assert("OWLNext Debug Break" && false);
187#endif
188
189//------------------------------------------------------------------------------
190// default BI_OWL_PACKING = 1
191#if !defined(BI_OWL_PACKING)
192#define BI_OWL_PACKING 1
193#endif
194
195//----------------------------------------------------------------------------
196#if defined(NO_OWL_NATIVECTRL_ALWAYS)
197#error OWLNext: NO_OWL_NATIVECTRL_ALWAYS is obsolete build options.
198#endif
199
200#if defined(OWL_NATIVECTRL_NEVER)
201#error OWLNext: OWL_NATIVECTRL_NEVER is obsolete build options.
202#endif
203
204//
205// Compatibility flags
206// Setting a lower compatility flag implies all the higher ones, so ensure they are set.
207//
208#if defined(OWL1_COMPAT) || defined(OWL2_COMPAT) || defined(NO_OWL1_COMPAT) || defined(NO_OWL2_COMPAT) || defined(NO_OWL5_COMPAT)
209#error OWLNext: OWL1_COMPAT and OWL2_COMPAT (as well as NO_OWL?_COMPAT variants) are obsolete build options.
210#endif
211
212#if defined(NO_OWL5_COMPAT)
213#pragma message("OWLNext: The NO_OWL5_COMPAT build option is obsolete.")
214#endif
215
216//----------------------------------------------------------------------------
217// _RTTI provides a convenient macro for switching on Borland's __rtti
218// keyword for finer grained control over generation of runtime type
219// information.
220//
221
222#if !defined(_RTTI)
223# define _RTTI __rtti
224#endif
225
226//----------------------------------------------------------------------------
227// These CAST macros encapsulate the new cast syntax in the ANSI/ISO
228// working paper. Note that TYPESAFE_DOWNCAST isn't as general as
229// dynamic_cast -- it only works on pointers.
230//
231// Usage:
232//
233// TYPESAFE_DOWNCAST(object,toClass)
234// Converts the pointer referred to by 'object' into a pointer to
235// an object of type 'toClass'. Note that the macro parameters to
236// TYPESAFE_DOWNCAST are in the opposite order from the rest of
237// the macros here. When using a compiler that supports new style
238// casts and runtime type information this is done with
239// dynamic_cast<> and will return 0 if the cast cannot be done.
240// When using a compiler that does not support new style casts and
241// runtime type information this is done with fake runtime type
242// information generated by the IMPLEMENT_CASTABLE macro.
243//
244// STATIC_CAST(targetType,object)
245// Converts the data object referred to by 'object' into the type
246// referred to by 'targetType'. When using a compiler that supports
247// new style casts, this is done with static_cast<> and will fail
248// if the cast cannot be done without runtime type information.
249// When using a compiler that does not support new style casts, this
250// is done with an old style dangerous cast.
251//
252// CONST_CAST(targetType,object)
253// Converts the data object referred to by 'object' into the type
254// referred to by 'targetType'. When using a compiler that supports
255// new style casts, this is done with const_cast<> and will fail
256// if the cast changes the type of the object in any way other than
257// adding or removing const and volatile qualifiers.
258// When using a compiler that does not support new style casts, this
259// is done with an old style dangerous cast.
260//
261// REINTERPRET_CAST(targetType,object)
262// Converts the data object referred to by 'object' into the type
263// referred to by 'targetType'. When using a compiler that supports
264// new style casts, this is done with reinterpret_cast<>.
265// When using a compiler that does not support new style casts, this
266// is done with an old style dangerous cast.
267//
268
269# define TYPESAFE_DOWNCAST(object,toClass)\
270 dynamic_cast<toClass * >(object)
271# define STATIC_CAST(targetType,object) \
272 static_cast<targetType >(object)
273# define CONST_CAST(targetType,object) \
274 const_cast<targetType >(object)
275# define REINTERPRET_CAST(targetType,object) \
276 reinterpret_cast<targetType >(object)
277
278# define GET_CLASS_CASTABLE_ID(classtype) typeid( classtype ).name()
279# define GET_OBJECT_CASTABLE_ID(object) typeid( object ).name()
280
281//----------------------------------------------------------------------------
282// Provide expansions for mutable and bool when appropriate.
283//
284
285
286namespace owl {
287
288 typedef bool TBool;
289# define BI_UNIQUE_BOOL
290
291 template<class T> inline bool ToBool(const T& t) {
292 return STATIC_CAST(bool,t);
293 }
294
295} // OWL namespace
296
297
298//----------------------------------------------------------------------------
299// Setup class, function and data modifier macros for OWL.
300//
301#define _OWLEXPORTDATA(p) __declspec(dllexport) p
302#define _OWLEXPORTFUNC(p) __declspec(dllexport) p
303#define _OWLEXPORTCFUNC(p) __declspec(dllexport) p _CCONV // owl _cdecl
304#define _OWLIMPORTDATA(p) __declspec(dllimport) p
305#define _OWLIMPORTFUNC(p) __declspec(dllimport) p
306#define _OWLIMPORTCFUNC(p) __declspec(dllimport) p _CCONV
307#define _OWLSTATICDATA(p) p
308#define _OWLSTATICFUNC(p) p
309#define _OWLSTATICCFUNC(p) p _CCONV
310
311#define _OWLEXPORTCLASS __declspec(dllexport)
312#define _OWLEXPORTCLASS_RTL __declspec(dllexport)
313#define _OWLIMPORTCLASS __declspec(dllimport)
314#define _OWLIMPORTCLASS_RTL __declspec(dllimport)
315#define _OWLSTATICCLASS
316#define _OWLSTATICCLASS_RTL
317
318#if defined(_BUILDOWLDLL)
319//JJH following guard for _OWLCLASS is here for the sake of
320//owl/include/private/winelib.h:19
321# if !defined(_OWLCLASS)
322# define _OWLCLASS _OWLEXPORTCLASS
323# endif
324//JJH the same as for _OWLCLASS
325# if !defined(_OWLCLASS_RTL)
326# define _OWLCLASS_RTL _OWLEXPORTCLASS_RTL
327# endif
328# define _OWLDATA _OWLEXPORTDATA
329# define _OWLFUNC _OWLEXPORTFUNC
330# define _OWLCFUNC _OWLEXPORTCFUNC
331#elif defined(_OWLDLL)
332# define _OWLCLASS _OWLIMPORTCLASS
333# define _OWLCLASS_RTL _OWLIMPORTCLASS_RTL
334# define _OWLDATA _OWLIMPORTDATA
335# define _OWLFUNC _OWLIMPORTFUNC
336# define _OWLCFUNC _OWLIMPORTCFUNC
337#else
338# define _OWLCLASS
339# define _OWLCLASS_RTL
340# define _OWLDATA(p) p
341# define _OWLFUNC(p) p
342# define _OWLCFUNC(p) p _CCONV
343#endif
344
345#define DECLARE_FUNC(rparm,ctype,fname) rparm (ctype fname)
346
347//----------------------------------------------------------------------------
348// Setup class modifier for user classes derived from Owl classes.
349// Force data segment load on method entry in case called back from Owl for
350// 16bit windows DLLs using Owl in a DLL
351//
352# define _USERCLASS
353
354//----------------------------------------------------------------------------
355
356//
357// Define library-wide function calling conventions. Must rebuild everything
358// if changed, and must use appropriate modifier on derived classes.
359//
360#if !defined(_CCONV)
361#define _CCONV __cdecl
362#endif
363
364#if !defined(BI_NO_SWAP_TMPL)
365template <class T> inline void Swap( T &a, T &b ) {
366 a ^= b; b ^= a; a ^= b;
367}
368#endif
369
370//
371/// Array element count
372/// Important: Only use this with an argument of array type.
373/// Passing a pointer to the array/first element will give the wrong results.
374/// Consider using boost::size or an equivalent function instead for safety.
375//
376#define COUNTOF(s) (sizeof(s) / sizeof((s)[0]))
377
378#if defined(BI_NOTHUNK)
379#pragma message("OWLNext: BI_NOTHUNK is unsafe and deprecated.")
380#endif
381
382#include <climits>
383
384#endif // OWL_PRIVATE_DEFS_H
Compiler-specific defines for Clang-based Embarcadero compilers.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
bool TBool
Definition defs.h:288
bool ToBool(const T &t)
Definition defs.h:291
void Swap(T &a, T &b)
Definition defs.h:365
#define STATIC_CAST(targetType, object)
Definition defs.h:271