PolyVox  0.2.1
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 
27 //Definitions needed to make library functions accessable
28 // See http://gcc.gnu.org/wiki/Visibility for more info.
29 #if defined _WIN32 || defined __CYGWIN__
30  #define POLYVOX_HELPER_IMPORT __declspec(dllimport)
31  #define POLYVOX_HELPER_EXPORT __declspec(dllexport)
32  #define POLYVOX_HELPER_LOCAL
33  #define POLYVOX_DEPRECATED __declspec(deprecated)
34 #else
35  #define POLYVOX_DEPRECATED __attribute__((deprecated))
36  #if __GNUC__ >= 4
37  #define POLYVOX_HELPER_IMPORT __attribute__ ((visibility("default")))
38  #define POLYVOX_HELPER_EXPORT __attribute__ ((visibility("default")))
39  #define POLYVOX_HELPER_LOCAL __attribute__ ((visibility("hidden")))
40  #else
41  #define POLYVOX_HELPER_IMPORT
42  #define POLYVOX_HELPER_EXPORT
43  #define POLYVOX_HELPER_LOCAL
44  #endif
45 #endif
46 
47 // Now we use the generic helper definitions above to define POLYVOX_API and POLYVOX_LOCAL.
48 // POLYVOX_API is used for the public API symbols. It either imports or exports (or does nothing for static build)
49 // POLYVOX_LOCAL is used for non-api symbols.
50 
51 #ifdef POLYVOX_SHARED // defined if PolyVox is compiled as a shared library
52  #ifdef POLYVOX_SHARED_EXPORTS // defined if we are building the PolyVox shared library (instead of using it)
53  #define POLYVOX_API POLYVOX_HELPER_EXPORT
54  #else
55  #define POLYVOX_API POLYVOX_HELPER_IMPORT
56  #endif // POLYVOX_SHARED_EXPORTS
57  #define POLYVOX_LOCAL POLYVOX_HELPER_LOCAL
58 #else // POLYVOX_SHARED is not defined: this means PolyVox is a static library.
59  #define POLYVOX_API
60  #define POLYVOX_LOCAL
61 #endif // POLYVOX_SHARED
62 
63 //Check which compiler we are using and work around unsupported features as necessary.
64 #if defined(_MSC_VER) && (_MSC_VER < 1600)
65  //To support old (pre-vc2010) Microsoft compilers we use boost to replace the
66  //std::shared_ptr and potentially other C++0x features. To use this capability you
67  //will need to make sure you have boost installed on your system.
68  #include <boost/smart_ptr.hpp>
69  #define polyvox_shared_ptr boost::shared_ptr
70 
71  #include <boost/function.hpp>
72  #define polyvox_function boost::function
73 
74  #include <boost/bind.hpp>
75  #define polyvox_bind boost::bind
76  #define polyvox_placeholder_1 _1
77  #define polyvox_placeholder_2 _2
78 
79  #include <boost/static_assert.hpp>
80  #define static_assert BOOST_STATIC_ASSERT
81 
82 
83  //As long as we're requiring boost, we'll use it to compensate
84  //for the missing cstdint header too.
85  #include <boost/cstdint.hpp>
86  using boost::int8_t;
87  using boost::int16_t;
88  using boost::int32_t;
89  using boost::uint8_t;
90  using boost::uint16_t;
91  using boost::uint32_t;
92 #else
93  //We have a decent compiler - use real C++0x features
94  #include <cstdint>
95  #include <functional>
96  #include <memory>
97  #define polyvox_shared_ptr std::shared_ptr
98  #define polyvox_function std::function
99  #define polyvox_bind std::bind
100  #define polyvox_placeholder_1 std::placeholders::_1
101  #define polyvox_placeholder_2 std::placeholders::_2
102  //#define static_assert static_assert //we can use this
103 #endif
104 
105 #endif