PolyVox  0.3.0-dev
Open source voxel management library
TypeDef.h
Go to the documentation of this file.
1 /*******************************************************************************
2 Copyright (c) 2005-2009 David Williams
3 
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7 
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11 
12  1. The origin of this software must not be misrepresented; you must not
13  claim that you wrote the original software. If you use this software
14  in a product, an acknowledgment in the product documentation would be
15  appreciated but is not required.
16 
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19 
20  3. This notice may not be removed or altered from any source
21  distribution.
22 *******************************************************************************/
23 
24 #ifndef __PolyVox_TypeDef_H__
25 #define __PolyVox_TypeDef_H__
26 
28 
29 //Definitions needed to make library functions accessable
30 // See http://gcc.gnu.org/wiki/Visibility for more info.
31 #if defined _WIN32 || defined __CYGWIN__
32  #define POLYVOX_HELPER_IMPORT __declspec(dllimport)
33  #define POLYVOX_HELPER_EXPORT __declspec(dllexport)
34  #define POLYVOX_HELPER_LOCAL
35  #define POLYVOX_DEPRECATED __declspec(deprecated)
36 #else
37  #define POLYVOX_DEPRECATED __attribute__((deprecated))
38  #if __GNUC__ >= 4
39  #define POLYVOX_HELPER_IMPORT __attribute__ ((visibility("default")))
40  #define POLYVOX_HELPER_EXPORT __attribute__ ((visibility("default")))
41  #define POLYVOX_HELPER_LOCAL __attribute__ ((visibility("hidden")))
42  #else
43  #define POLYVOX_HELPER_IMPORT
44  #define POLYVOX_HELPER_EXPORT
45  #define POLYVOX_HELPER_LOCAL
46  #endif
47 #endif
48 
49 #if defined SWIG
50  //Do nothing in this case
51 #else
52  #undef POLYVOX_DEPRECATED
53  #define POLYVOX_DEPRECATED //Define it to nothing to avoid warnings
54 #endif
55 
56 // Now we use the generic helper definitions above to define POLYVOX_API and POLYVOX_LOCAL.
57 // POLYVOX_API is used for the public API symbols. It either imports or exports (or does nothing for static build)
58 // POLYVOX_LOCAL is used for non-api symbols.
59 
60 #ifdef POLYVOX_SHARED // defined if PolyVox is compiled as a shared library
61  #ifdef POLYVOX_SHARED_EXPORTS // defined if we are building the PolyVox shared library (instead of using it)
62  #define POLYVOX_API POLYVOX_HELPER_EXPORT
63  #else
64  #define POLYVOX_API POLYVOX_HELPER_IMPORT
65  #endif // POLYVOX_SHARED_EXPORTS
66  #define POLYVOX_LOCAL POLYVOX_HELPER_LOCAL
67 #else // POLYVOX_SHARED is not defined: this means PolyVox is a static library.
68  #define POLYVOX_API
69  #define POLYVOX_LOCAL
70 #endif // POLYVOX_SHARED
71 
72 //Check which compiler we are using and work around unsupported features as necessary.
73 #if defined(_MSC_VER) && (_MSC_VER < 1600)
74  //To support old (pre-vc2010) Microsoft compilers we use boost to replace the
75  //std::shared_ptr and potentially other C++0x features. To use this capability you
76  //will need to make sure you have boost installed on your system.
77  #include <boost/function.hpp>
78  #define polyvox_function boost::function
79 
80  #include <boost/bind.hpp>
81  #define polyvox_bind boost::bind
82  #define polyvox_placeholder_1 _1
83  #define polyvox_placeholder_2 _2
84 #else
85  //We have a decent compiler - use real C++0x features
86  #include <functional>
87  #define polyvox_function std::function
88  #define polyvox_bind std::bind
89  #define polyvox_placeholder_1 std::placeholders::_1
90  #define polyvox_placeholder_2 std::placeholders::_2
91 #endif
92 
93 #if defined(HAS_CXX11_CONSTEXPR)
94  #define polyvox_constexpr_const constexpr //constexpr which falls back to const
95  #define polyvox_constexpr constexpr //constexpr which falls back to nothing
96 #else
97  #define polyvox_constexpr_const const
98  #define polyvox_constexpr
99 #endif
100 
101 #if defined(HAS_CXX11_CSTDINT_H)
102  #include <cstdint>
103 #else
104  typedef signed char int8_t;
105  typedef unsigned char uint8_t;
106  typedef short int16_t;
107  typedef unsigned short uint16_t;
108  typedef long int32_t;
109  typedef unsigned long uint32_t;
110 #endif
111 
112 #if defined(HAS_CXX11_SHARED_PTR)
113  #include <memory>
114  #define polyvox_shared_ptr std::shared_ptr
115 #else
116  #include <boost/smart_ptr.hpp>
117  #define polyvox_shared_ptr boost::shared_ptr
118 #endif
119 
120 #endif