2006-04-12 01:59:08 +02:00
|
|
|
/**
|
|
|
|
* =========================================================================
|
|
|
|
* File : precompiled.h
|
|
|
|
* Project : 0 A.D.
|
|
|
|
* Description : precompiled header. must be the first non-comment part
|
|
|
|
* : of every source file (VC6/7 requirement).
|
|
|
|
*
|
|
|
|
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
|
|
|
|
* =========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2002-2005 Jan Wassenberg
|
|
|
|
*
|
|
|
|
* Redistribution and/or modification are also permitted under the
|
|
|
|
* terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation (version 2 or later, at your option).
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
2006-01-29 20:46:31 +01:00
|
|
|
// if the compiler supports PCH (i.e. HAVE_PCH is defined), this
|
2005-01-31 00:09:51 +01:00
|
|
|
// tries to include all headers that may be needed. otherwise, all source
|
|
|
|
// files will still need to include this (for various global fixes and the
|
|
|
|
// memory trackers), but additionally include all required headers.
|
|
|
|
//
|
|
|
|
// this policy yields the best compile performance with or without PCH.
|
2004-06-04 14:41:53 +02:00
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
// must come before warning disables.
|
|
|
|
#include "lib/config.h"
|
|
|
|
|
|
|
|
// disable some common and annoying warnings
|
|
|
|
// (done as soon as possible so that headers below are covered)
|
|
|
|
#if MSC_VERSION
|
|
|
|
// .. temporarily disabled W4 (unimportant but ought to be fixed)
|
|
|
|
# pragma warning(disable:4201) // nameless struct (Matrix3D)
|
|
|
|
# pragma warning(disable:4244) // conversion from uintN to uint8
|
|
|
|
// .. permanently disabled W4
|
|
|
|
# pragma warning(disable:4127) // conditional expression is constant; rationale: see STMT in lib.h.
|
2005-07-03 02:50:49 +02:00
|
|
|
# pragma warning(disable:4996) // function is deprecated
|
|
|
|
# pragma warning(disable:4786) // identifier truncated to 255 chars
|
2006-02-03 21:36:15 +01:00
|
|
|
# pragma warning(disable:4351) // yes, default init of array entries is desired
|
2005-08-14 04:07:12 +02:00
|
|
|
// .. disabled only for the precompiled headers
|
|
|
|
# pragma warning(disable:4702) // unreachable code (frequent in STL)
|
2005-08-09 18:23:19 +02:00
|
|
|
// .. VS2005 code analysis (very frequent ones)
|
|
|
|
# if MSC_VERSION >= 1400
|
2005-07-03 02:50:49 +02:00
|
|
|
# pragma warning(disable:6011) // dereferencing NULL pointer
|
|
|
|
# pragma warning(disable:6246) // local declaration hides declaration of the same name in outer scope
|
|
|
|
# endif
|
2004-06-04 14:41:53 +02:00
|
|
|
#endif
|
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
//
|
|
|
|
// headers made available everywhere for convenience
|
|
|
|
//
|
|
|
|
|
2005-06-22 05:23:22 +02:00
|
|
|
#include "lib/types.h"
|
2006-09-22 15:19:40 +02:00
|
|
|
#include "lib/lib_errors.h"
|
2005-06-22 05:23:22 +02:00
|
|
|
#include "lib/string_s.h" // CRT secure string
|
2007-04-30 16:35:19 +02:00
|
|
|
#include "lib/debug.h"
|
|
|
|
#include "lib/sysdep/compiler.h"
|
|
|
|
#include "lib/sysdep/stl.h"
|
|
|
|
#include "lib/posix/posix.h"
|
2006-06-22 20:26:08 +02:00
|
|
|
|
2005-02-28 16:50:35 +01:00
|
|
|
|
2005-01-31 00:09:51 +01:00
|
|
|
//
|
|
|
|
// memory headers
|
|
|
|
//
|
2004-05-08 03:18:15 +02:00
|
|
|
|
2005-01-31 00:09:51 +01:00
|
|
|
// these are all system headers that contain "new", "malloc" etc.; they must
|
|
|
|
// come before the memory tracker headers to avoid conflicts with their
|
|
|
|
// macros. therefore, they are always included, even if !HAVE_PCH.
|
2004-05-08 03:18:15 +02:00
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#if OS_WIN
|
|
|
|
# include <malloc.h>
|
2005-01-31 00:09:51 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <new>
|
|
|
|
#include <memory>
|
2005-08-09 18:23:19 +02:00
|
|
|
#include <valarray> // free() member function
|
2005-01-31 00:09:51 +01:00
|
|
|
|
2005-02-28 16:50:35 +01:00
|
|
|
|
2005-01-31 00:09:51 +01:00
|
|
|
//
|
|
|
|
// headers to be precompiled
|
|
|
|
//
|
|
|
|
|
|
|
|
// candidates are all system headers we may possibly need or large/rarely
|
|
|
|
// changed project headers; everything placed in here will not need to be
|
|
|
|
// compiled every time. however, if they change, the project will have to be
|
|
|
|
// completely rebuilt. (slow!)
|
|
|
|
//
|
|
|
|
// if the compiler doesn't support precompiled headers (i.e. !HAVE_PCH),
|
|
|
|
// including anything here would actually slow things down, because we might
|
|
|
|
// not otherwise need some of these headers. therefore, do nothing and rely
|
|
|
|
// on all source files (additionally) including everything they need.
|
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#if HAVE_PCH
|
2005-01-31 00:09:51 +01:00
|
|
|
|
2005-06-25 09:43:13 +02:00
|
|
|
// all new-form C library headers
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <cassert>
|
|
|
|
#include <cctype>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <cerrno>
|
|
|
|
#include <cfloat>
|
2006-06-25 22:58:03 +02:00
|
|
|
//#include <ciso646> // defines e.g. "and" to "&". unnecessary and causes trouble with asm.
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <climits>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <clocale>
|
2006-09-02 23:20:25 +02:00
|
|
|
#include <cmath>
|
2006-01-29 20:46:31 +01:00
|
|
|
// Including setjmp.h here causes incompatibilities with libpng on Debian/Ubuntu
|
|
|
|
//#include <csetjmp>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <csignal>
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <cstdarg>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <cstring>
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <ctime>
|
|
|
|
#include <cwchar>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <cwctype>
|
2005-01-31 00:09:51 +01:00
|
|
|
|
2005-06-25 09:43:13 +02:00
|
|
|
// all C++98 STL headers
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <algorithm>
|
2004-06-01 19:34:12 +02:00
|
|
|
#include <deque>
|
2004-05-08 03:18:15 +02:00
|
|
|
#include <functional>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <iterator>
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <list>
|
|
|
|
#include <map>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <memory>
|
2004-05-08 03:18:15 +02:00
|
|
|
#include <numeric>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <queue>
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <set>
|
|
|
|
#include <stack>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <utility>
|
2005-01-31 00:09:51 +01:00
|
|
|
#include <vector>
|
2004-05-24 22:25:48 +02:00
|
|
|
|
2005-06-25 09:43:13 +02:00
|
|
|
// all other C++98 headers
|
|
|
|
#include <bitset>
|
|
|
|
#include <complex>
|
|
|
|
#include <exception>
|
|
|
|
#include <fstream>
|
|
|
|
#include <iomanip>
|
|
|
|
#include <ios>
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <iostream>
|
|
|
|
#include <istream>
|
|
|
|
#include <limits>
|
|
|
|
#include <locale>
|
|
|
|
#include <new>
|
|
|
|
#include <ostream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <streambuf>
|
|
|
|
#include <string>
|
2006-01-29 19:23:47 +01:00
|
|
|
#include <sstream>
|
2005-06-25 09:43:13 +02:00
|
|
|
#include <typeinfo>
|
|
|
|
#include <valarray>
|
|
|
|
|
|
|
|
// STL extensions
|
2005-08-09 18:23:19 +02:00
|
|
|
#if GCC_VERSION
|
2005-06-01 22:12:45 +02:00
|
|
|
# include <ext/hash_map>
|
|
|
|
# include <ext/hash_set>
|
|
|
|
#else
|
|
|
|
# include <hash_map>
|
|
|
|
# include <hash_set>
|
|
|
|
#endif
|
|
|
|
|
2005-01-31 00:09:51 +01:00
|
|
|
// (further headers to be precompiled go here)
|
2004-06-30 18:06:05 +02:00
|
|
|
|
2005-08-09 18:23:19 +02:00
|
|
|
#endif // #if HAVE_PCH
|
2005-01-23 19:23:29 +01:00
|
|
|
|
2005-08-14 04:07:12 +02:00
|
|
|
// restore temporarily-disabled warnings
|
|
|
|
#if MSC_VERSION
|
|
|
|
# pragma warning(default:4702)
|
|
|
|
#endif
|
|
|
|
|
2005-01-31 00:09:51 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// memory trackers
|
|
|
|
//
|
|
|
|
|
|
|
|
// these must be included from every file to make sure all allocations
|
|
|
|
// are hooked. placing in the precompiled header is more convenient than
|
|
|
|
// manually #including from every file, but requires that all system
|
|
|
|
// headers containing "new", "malloc" etc. come before this (see above).
|
2005-08-09 18:23:19 +02:00
|
|
|
//
|
|
|
|
// note: mmgr.h activates mmgr or the VC debug heap or nothing depending
|
|
|
|
// on CONFIG_USE_MMGR and HAVE_VC_DEBUG_ALLOC settings.
|
2005-06-22 05:23:22 +02:00
|
|
|
# include "mmgr.h"
|
2007-02-25 22:11:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
// Boost
|
|
|
|
#include <boost/utility.hpp> // noncopyable
|