Geogram Version 1.8.5
A programming library of geometric algorithms
Loading...
Searching...
No Matches
common.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef GEOGRAM_BASIC_COMMON
41#define GEOGRAM_BASIC_COMMON
42
43#include <geogram/api/defs.h>
44
45// iostream should be included before anything else,
46// otherwise 'cin', 'cout' and 'cerr' will be uninitialized.
47#include <iostream>
48
61namespace GEO {
62
66 enum {
67 GEOGRAM_NO_HANDLER = 0,
68 GEOGRAM_INSTALL_HANDLERS = 1
69 };
70
85 void GEOGRAM_API initialize(int flags = GEOGRAM_INSTALL_HANDLERS);
86
94 void GEOGRAM_API terminate();
95}
96
174#if (defined(NDEBUG) || defined(GEOGRAM_PSM)) && !defined(GEOGRAM_PSM_DEBUG)
175#undef GEO_DEBUG
176#undef GEO_PARANOID
177#else
178#define GEO_DEBUG
179#define GEO_PARANOID
180#endif
181
182// =============================== LINUX defines ===========================
183
184#if defined(__ANDROID__)
185#define GEO_OS_ANDROID
186#endif
187
188#if defined(__linux__)
189
190#define GEO_OS_LINUX
191#define GEO_OS_UNIX
192
193#ifndef GEO_OS_ANDROID
194#define GEO_OS_X11
195#endif
196
197#if defined(_OPENMP)
198# define GEO_OPENMP
199#endif
200
201#if defined(__INTEL_COMPILER)
202# define GEO_COMPILER_INTEL
203#elif defined(__clang__)
204# define GEO_COMPILER_CLANG
205#elif defined(__GNUC__)
206# define GEO_COMPILER_GCC
207#else
208# error "Unsupported compiler"
209#endif
210
211// The following works on GCC and ICC
212#if defined(__x86_64)
213# define GEO_ARCH_64
214#else
215# define GEO_ARCH_32
216#endif
217
218// =============================== WINDOWS defines =========================
219
220#elif defined(_WIN32) || defined(_WIN64)
221
222#define GEO_OS_WINDOWS
223
224#if defined(_OPENMP)
225# define GEO_OPENMP
226#endif
227
228#if defined(_MSC_VER)
229# define GEO_COMPILER_MSVC
230#elif defined(__MINGW32__) || defined(__MINGW64__)
231# define GEO_COMPILER_MINGW
232#endif
233
234#if defined(_WIN64)
235# define GEO_ARCH_64
236#else
237# define GEO_ARCH_32
238#endif
239
240// =============================== APPLE defines ===========================
241
242#elif defined(__APPLE__)
243
244#define GEO_OS_APPLE
245#define GEO_OS_UNIX
246
247#if defined(_OPENMP)
248# define GEO_OPENMP
249#endif
250
251#if defined(__clang__)
252# define GEO_COMPILER_CLANG
253#elif defined(__GNUC__)
254# define GEO_COMPILER_GCC
255#else
256# error "Unsupported compiler"
257#endif
258
259#if defined(__x86_64) || defined(__ppc64__) || defined(__arm64__) || defined(__aarch64__)
260# define GEO_ARCH_64
261#else
262# define GEO_ARCH_32
263#endif
264
265// =============================== Emscripten defines ======================
266
267#elif defined(__EMSCRIPTEN__)
268
269#define GEO_OS_UNIX
270#define GEO_OS_LINUX
271#define GEO_OS_EMSCRIPTEN
272#define GEO_ARCH_64
273#define GEO_COMPILER_EMSCRIPTEN
274
275// =============================== Unsupported =============================
276#else
277#error "Unsupported operating system"
278#endif
279
280#if defined(GEO_COMPILER_GCC) || \
281 defined(GEO_COMPILER_CLANG) || \
282 defined(GEO_COMPILER_MINGW) || \
283 defined(GEO_COMPILER_EMSCRIPTEN)
284#define GEO_COMPILER_GCC_FAMILY
285#endif
286
287#ifdef DOXYGEN_ONLY
288// Keep doxygen happy
289#define GEO_OS_WINDOWS
290#define GEO_OS_APPLE
291#define GEO_OS_ANDROID
292#define GEO_ARCH_32
293#define GEO_COMPILER_INTEL
294#define GEO_COMPILER_MSVC
295#endif
296
301#define CPP_CONCAT_(A, B) A ## B
302
307#define CPP_CONCAT(A, B) CPP_CONCAT_(A, B)
308
309#if defined(GOMGEN)
310#define GEO_NORETURN
311#elif defined(GEO_COMPILER_GCC_FAMILY) || \
312 defined(GEO_COMPILER_INTEL)
313#define GEO_NORETURN __attribute__((noreturn))
314#else
315#define GEO_NORETURN
316#endif
317
318#if defined(GOMGEN)
319#define GEO_NORETURN_DECL
320#elif defined(GEO_COMPILER_MSVC)
321#define GEO_NORETURN_DECL __declspec(noreturn)
322#else
323#define GEO_NORETURN_DECL
324#endif
325
326#if defined(GEO_COMPILER_CLANG) || defined(GEO_COMPILER_EMSCRIPTEN)
327#if __has_feature(cxx_noexcept)
328#define GEO_NOEXCEPT noexcept
329#endif
330#endif
331
332// For Graphite GOM generator (swig is confused by throw() specifier)
333#ifdef GOMGEN
334#define GEO_NOEXCEPT
335#endif
336
337#ifndef GEO_NOEXCEPT
338#define GEO_NOEXCEPT throw()
339#endif
340
341#define FOR(I,UPPERBND) for(index_t I = 0; I<index_t(UPPERBND); ++I)
342
343// Silence warnings for alloca()
344// We use it at different places to allocate objects on the stack
345// (for instance, in multi-precision predicates).
346#ifdef GEO_COMPILER_CLANG
347#pragma GCC diagnostic ignored "-Walloca"
348#endif
349
350#endif
351
Basic definitions for the Geogram C API.
Global Vorpaline namespace.
Definition algorithm.h:64
void terminate()
Cleans up Geogram.
void initialize(int flags=GEOGRAM_INSTALL_HANDLERS)
Initialize Geogram.