Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
Macro.h
Go to the documentation of this file.
1// ----------------------------------------------------------------------------
2// - Open3D: www.open3d.org -
3// ----------------------------------------------------------------------------
4// Copyright (c) 2018-2024 www.open3d.org
5// SPDX-License-Identifier: MIT
6// ----------------------------------------------------------------------------
7
8#pragma once
9
10#include <cassert>
11
12// https://gcc.gnu.org/wiki/Visibility updated to use C++11 attribute syntax
13// In Open3D, we set symbol visibility based on folder / cmake target through
14// cmake. e.g. all symbols in kernel folders are hidden. These macros allow fine
15// grained control over symbol visibility.
16#if defined(_WIN32) || defined(__CYGWIN__)
17#define OPEN3D_DLL_IMPORT __declspec(dllimport)
18#define OPEN3D_DLL_EXPORT __declspec(dllexport)
19#define OPEN3D_DLL_LOCAL
20#else
21#define OPEN3D_DLL_IMPORT [[gnu::visibility("default")]]
22#define OPEN3D_DLL_EXPORT [[gnu::visibility("default")]]
23#define OPEN3D_DLL_LOCAL [[gnu::visibility("hidden")]]
24#endif
25
26#ifdef OPEN3D_STATIC
27#define OPEN3D_API
28#define OPEN3D_LOCAL
29#else
30#define OPEN3D_LOCAL OPEN3D_DLL_LOCAL
31#if defined(OPEN3D_ENABLE_DLL_EXPORTS)
32#define OPEN3D_API OPEN3D_DLL_EXPORT
33#else
34#define OPEN3D_API OPEN3D_DLL_IMPORT
35#endif
36#endif
37
38// Compiler-specific function macro.
39// Ref: https://stackoverflow.com/a/4384825
40#ifdef _WIN32
41#define OPEN3D_FUNCTION __FUNCSIG__
42#else
43#define OPEN3D_FUNCTION __PRETTY_FUNCTION__
44#endif
45
46// Assertion for CUDA device code.
47// Usage:
48// OPEN3D_ASSERT(condition);
49// OPEN3D_ASSERT(condition && "Error message");
50// For host-only code, consider using utility::LogError();
51#define OPEN3D_ASSERT(...) assert((__VA_ARGS__))