NeoN
A framework for CFD software
Loading...
Searching...
No Matches
visibility.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7/* @brief marks a type whose RTTI must be shared across shared-object boundaries.
8 *
9 * The `_neon` Python extension is built `-fvisibility=hidden` (nanobind's default), which by
10 * default also hides the typeinfo emitted for a non-polymorphic class. `std::any` dispatches on
11 * `type_info` identity, so a payload boxed inside `_neon` (e.g. a Dictionary built by the
12 * Dictionary bindings) is unrecognisable to an `any_cast` compiled into libNeoN — `isDict()`
13 * returns false and `get<TokenList>()` throws `bad any cast`. Forcing default visibility makes
14 * the typeinfo a coalesced weak symbol so both objects agree on the type.
15 *
16 * Apply to any type that travels through `std::any` (or is caught as an exception) across the
17 * libNeoN / `_neon` boundary.
18 */
19#if defined(_WIN32) || defined(__CYGWIN__)
20#define NEON_TYPE_VISIBLE
21#else
22#define NEON_TYPE_VISIBLE __attribute__((visibility("default")))
23#endif