1// header.h -- 2// $Id: header.h 1230 2007-03-09 15:58:53Z jcw $ 3// This is part of Metakit, the homepage is http://www.equi4.com/metakit.html 4 5/** @file 6 * The internal header included in all source files 7 */ 8 9#ifndef __HEADER_H__ 10#define __HEADER_H__ 11 12///////////////////////////////////////////////////////////////////////////// 13 14#include "config.h" 15 16///////////////////////////////////////////////////////////////////////////// 17// A number of preprocessor options are used in the source code 18// 19// q4_DOS MS-DOS real-mode OS 20// q4_MAC Apple Macintosh OS 21// q4_UNIX Unix, any flavor 22// q4_VMS DEC OpenVMS OS 23// q4_WIN Microsoft Windows OS, any flavor 24// q4_WIN32 Microsoft Windows OS, 32-bit 25// q4_WINCE Microsoft Windows OS, embedded 26// 27// q4_MFC Microsoft MFC framework 28// q4_STD Standard STL version 29// q4_UNIV Universal version 30// 31// q4_BOOL compiler supports bool datatype 32// q4_CHECK enable assertion checks 33// q4_FIX manual header fix (see above) 34// q4_INLINE enable inline expansion 35// q4_KITDLL compile as DLL (shared library) 36// q4_MULTI compile for multi-threading 37// q4_NOLIB do not add automatic lib linkage (MSVC5) 38// q4_NO_NS don't use namespaces for STL 39// q4_OK assume all software is perfect 40// q4_STRICT do not disable any compiler warnings 41// q4_TINY small version, no floating point 42// 43///////////////////////////////////////////////////////////////////////////// 44 45#define __K4CONF_H__ // skip section in "mk4.h", since we use "header.h" 46 47// if neither MFC nor STD are specified, default to Universal version 48#if !q4_MFC && !q4_STD && !defined (q4_UNIV) 49#define q4_UNIV 1 50#endif 51 52///////////////////////////////////////////////////////////////////////////// 53// You can either use '#define q4_xxx 1' to flag the choice of an OS, or 54// use a '#define d4_OS_H "file.h"' to force inclusion of a header later. 55 56#if defined (__MINGW32__) 57#define d4_OS_H "win.h" 58#elif defined (MSDOS) && defined (__GNUC__) 59#define q4_DOS 1 60#elif defined(unix) || defined(__unix__) || defined(__GNUC__) || \ 61defined(_AIX) || defined(__hpux) 62#define q4_UNIX 1 63#elif defined (__VMS) 64#define q4_VMS 1 65#elif defined (macintosh) 66#define q4_MAC 1 67#elif !defined (d4_OS_H) 68#define d4_OS_H "win.h" 69#endif 70 71///////////////////////////////////////////////////////////////////////////// 72// Use '#define q4_xxx 1' to flag the choice of a CPU. 73 74#if defined (_M_I86) || defined (_M_IX86) || defined (i386) 75#define q4_I86 1 76#if defined (_M_I86SM) 77#define q4_TINY 1 78#endif 79#elif defined (__powerc) 80#define q4_PPC 1 81#elif defined (__alpha) 82#define q4_AXP 1 83#define q4_LONG64 1 84#elif defined (__VMS) 85#define q4_VAX 1 86#else 87#define q4_M68K 1 88#endif 89 90///////////////////////////////////////////////////////////////////////////// 91// Use '#define q4_xxx 1' to flag the choice of an IDE, and optionally also 92// add '#include "file.h"' to force inclusion of a header file right here. 93 94#if defined (__BORLANDC__) // Borland C++ 95#include "borc.h" 96#elif defined (__DECCXX) // DEC C++ 97#define q4_DECC 1 98#elif defined (__GNUC__) // GNU C++ 99#include "gnuc.h" 100#elif defined (__MWERKS__) // Metrowerks CodeWarrior C++ 101#include "mwcw.h" 102#elif defined (_MSC_VER) // Microsoft Visual C++ 103#include "msvc.h" 104#elif defined (__SC__) // Symantec C++ 105#define q4_SYMC 1 106#elif defined (__WATCOMC__) // Watcom C++ 107#define q4_WATC 1 108#endif 109 110///////////////////////////////////////////////////////////////////////////// 111// Some of the options take precedence over others 112 113#if !q4_BOOL && !q4_STD // define a bool datatype 114#define false 0 115#define true 1 116#define bool int 117#endif 118 119#if !q4_CHECK // disable assertions 120#undef d4_assert 121#define d4_dbgdef(x) 122#define d4_assert(x) 123#endif 124 125#if q4_NO_NS // don't use namespaces 126#define d4_std 127#else 128#define d4_std std 129#endif 130 131#if HAVE_MEMMOVE 132#define d4_memmove(d,s,n) memmove(d,s,n) 133#elif HAVE_BCOPY 134#define d4_memmove(d,s,n) bcopy(s,d,n) 135#else 136#define d4_memmove f4_memmove 137extern void f4_memmove(void *d, const void *s, int n); 138#endif 139 140typedef unsigned char t4_byte; // create typedefs for t4_byte, etc. 141 142#if (!defined(__APPLE__) && SIZEOF_LONG == 8) || (defined(__APPLE__) && defined(__LP64__)) 143typedef int t4_i32; // longs are 64b, so int must be 32b 144#else 145typedef long t4_i32; // longs aren't 64b, so they are 32b 146#endif 147 148///////////////////////////////////////////////////////////////////////////// 149// Include header files which contain additional os/cpu/ide/fw specifics 150 151#ifdef d4_OS_H // operating system dependencies 152#include d4_OS_H 153#endif 154 155///////////////////////////////////////////////////////////////////////////// 156// Several defines should always be set 157 158#ifndef d4_assert // assertion macro 159#include <assert.h> 160#define d4_assert assert 161#endif 162 163#ifndef d4_dbgdef // conditionally compiled 164#ifdef NDEBUG 165#define d4_dbgdef(x) 166#else 167#define d4_dbgdef(x) x 168#endif 169#endif 170 171#ifndef d4_new // heap allocator 172#define d4_new new 173#endif 174 175#ifndef d4_reentrant // thread-local storage 176#define d4_reentrant 177#endif 178 179///////////////////////////////////////////////////////////////////////////// 180// Debug logging option, called internally where properties are modified 181 182#if q4_LOGPROPMODS 183void f4_DoLogProp(const c4_Handler *, int, const char *, int); 184#else 185#define f4_LogPropMods(a,b) 0 186#endif 187 188///////////////////////////////////////////////////////////////////////////// 189// Public definitions, plus a few more framework-specific ones 190 191#include "mk4.h" 192 193#if q4_MFC 194#include "mfc.h" 195#elif q4_STD 196#include "std.h" 197#elif q4_UNIV 198#include "univ.h" 199#endif 200 201#ifdef _MSC_VER 202#pragma warning(disable: 4100 4127 4135 4244 4511 4512 4514) 203#endif 204 205#include <string.h> 206 207///////////////////////////////////////////////////////////////////////////// 208// Report unexpected combinations of settings 209 210#if !q4_FIX 211#if (q4_DOS+q4_MAC+q4_UNIX+q4_VMS+q4_WIN) != 1 212#error Exactly one operating system should have been defined 213#endif 214#if (q4_MFC+q4_STD+q4_UNIV) != 1 215#error Exactly one container library should have been defined 216#endif 217#endif 218 219///////////////////////////////////////////////////////////////////////////// 220 221#endif 222