v0.1.0
Fast, portable C library for geometry input/output
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules
global.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** gmio
3 ** Copyright Fougue (24 Jun. 2016)
4 ** contact@fougue.pro
5 **
6 ** This software is a reusable library whose purpose is to provide complete
7 ** I/O support for various CAD file formats (eg. STL)
8 **
9 ** This software is governed by the CeCILL-B license under French law and
10 ** abiding by the rules of distribution of free software. You can use,
11 ** modify and/ or redistribute the software under the terms of the CeCILL-B
12 ** license as circulated by CEA, CNRS and INRIA at the following URL
13 ** "http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html".
14 ****************************************************************************/
15 
27 #ifndef GMIO_GLOBAL_H
28 #define GMIO_GLOBAL_H
29 
30 /* "config.h" is generated by cmake, it should reside in the out-of-source
31  * build dir.
32  * In CMakeFiles.txt, the directory where resides "config.h" is added to the
33  * include path list
34  */
35 #include "config.h"
36 
37 /* GMIO_OS_WIN */
38 #if defined(WIN64) || defined(_WIN64) || defined(__WIN64__) \
39  || defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
40  || defined(__NT__)
41 # define GMIO_OS_WIN
42 #endif
43 
44 /* GMIO_OS_LINUX */
45 #if defined(__linux) || defined(__linux__) || defined(linux)
46 # define GMIO_OS_LINUX
47 #endif
48 
49 /* GMIO_OS_MAC */
50 #if defined(__APPLE__)
51 # define GMIO_OS_MAC
52 #endif
53 
54 /* GMIO_DECL_IMPORT */
55 /* GMIO_DECL_EXPORT */
56 #ifdef GMIO_OS_WIN
57 # define GMIO_DECL_EXPORT __declspec(dllexport)
58 # define GMIO_DECL_IMPORT __declspec(dllimport)
59 #else
60 
61 # define GMIO_DECL_EXPORT
62 
63 # define GMIO_DECL_IMPORT
64 #endif
65 
66 /* GMIO_API */
67 #ifdef GMIO_DLL
68 # ifdef GMIO_MAKING_DLL
69 # define GMIO_API GMIO_DECL_EXPORT
70 # else
71 # define GMIO_API GMIO_DECL_IMPORT
72 # endif /* GMIO_MAKING_DLL */
73 #else
74 
76 # define GMIO_API
77 #endif
78 
79 /* GMIO_HAVE_INT64_TYPE */
80 #if defined(GMIO_HAVE_INT64_T) \
81  || defined(GMIO_HAVE_MSVC_INT64) \
82  || defined(GMIO_HAVE_LONG_LONG)
83 # define GMIO_HAVE_INT64_TYPE
84 #endif
85 
86 /* Typedefs for specific width integers */
87 #ifdef GMIO_HAVE_STDINT_H
88 # include <stdint.h>
89 #else
90 typedef char int8_t;
91 typedef unsigned char uint8_t;
92 
93 # if GMIO_SIZEOF_SHORT == 2
94 typedef short int16_t;
95 typedef unsigned short uint16_t;
96 # else
97 # error Not supported: sizeof(short) != 2
98 # endif
99 
100 # if GMIO_SIZEOF_INT == 4
101 typedef int int32_t;
102 typedef unsigned int uint32_t;
103 # elif GMIO_SIZEOF_LONG == 4
104 typedef long int32_t;
105 typedef unsigned long uint32_t;
106 # else
107 # error Failed to find a 32bit integer type with 'int' and 'long'
108 # endif
109 
110 # ifndef GMIO_HAVE_INT64_T
111 # if defined(GMIO_HAVE_MSVC_INT64)
112 typedef __int64_t int64_t;
113 typedef unsigned __int64_t uint64_t;
114 # elif defined(GMIO_HAVE_LONG_LONG)
115 typedef long long int64_t;
116 typedef unsigned long long uint64_t;
117 # endif
118 #endif
119 
120 # ifdef GMIO_HAVE_INT64_TYPE
121 typedef int64_t intmax_t;
122 typedef uint64_t uintmax_t;
123 # else
124 typedef int32_t intmax_t;
125 typedef uint32_t uintmax_t;
126 # endif
127 
128 #endif
129 
130 /* GMIO_HAVE_STDBOOL_H */
131 #ifdef GMIO_HAVE_STDBOOL_H
132 # include <stdbool.h>
133 #elif !defined(DOXYGEN) && !defined(__cplusplus)
134 typedef int bool;
135 enum gmio_bool_value
136 {
137  false = 0,
138  true = 1
139 };
140 #endif
141 
142 /* GMIO_UNUSED */
144 #define GMIO_UNUSED(x) (void)x;
145 
146 /* GMIO_INLINE */
147 #ifndef GMIO_INLINE
148 # if defined(__GNUC__)
149 # define GMIO_INLINE __inline__ static /* Compatible with C90 */
150 # elif defined(_MSC_VER)
151 # define GMIO_INLINE __inline static
152 # elif !defined(DOXYGEN)
153 # define GMIO_INLINE static
154 # else
155 
156 # define GMIO_INLINE
157 # endif
158 #endif
159 
160 /* GMIO_RESTRICT */
161 #ifndef GMIO_RESTRICT
162 # if defined(__GNUC__)
163 # define GMIO_RESTRICT __restrict__ /* Compatible with C90 */
164 # elif defined(_MSC_VER)
165 # define GMIO_RESTRICT __restrict
166 # elif defined(GMIO_HAVE_C99_RESTRICT) /* TODO: add cmake detectection */
167 # define GMIO_RESTRICT restrict
168 # else
169 
170 # define GMIO_RESTRICT
171 # endif
172 #endif
173 
174 /* GMIO_C_LINKAGE_BEGIN */
175 /* GMIO_C_LINKAGE_END */
176 #ifdef __cplusplus
177 # define GMIO_C_LINKAGE_BEGIN extern "C" {
178 # define GMIO_C_LINKAGE_END }
179 #else
180 
181 # define GMIO_C_LINKAGE_BEGIN
182 
183 # define GMIO_C_LINKAGE_END
184 #endif
185 
186 /* GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE */
187 /* GMIO_PRAGMA_MSVC_WARNING_POP */
188 #if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual C++ 2008 */
189 # define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__) \
190  __pragma(warning(push)) \
191  __pragma(warning(disable: __code__))
192 # define GMIO_PRAGMA_MSVC_WARNING_POP() \
193  __pragma(warning(pop))
194 #else
195 
203 # define GMIO_PRAGMA_MSVC_WARNING_PUSH_AND_DISABLE(__code__)
204 
211 # define GMIO_PRAGMA_MSVC_WARNING_POP()
212 #endif
213 
215 #define GMIO_ARRAY_SIZE(array) sizeof(array) / sizeof(*array)
216 
217 #endif /* GMIO_GLOBAL_H */
218 
Fougue © 2016