VTK  9.3.20240425
vtkCompiler.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3
4#ifndef vtkCompiler_h
5#define vtkCompiler_h
6
7/*--------------------------------------------------------------------------*/
8/* Compiler backend */
9/* Be careful modifying this -- order is important. */
10#if defined(_MSC_VER)
11/* MSVC 2015+ can use a clang frontend, so we want to label it only as MSVC
12 * and not MSVC and clang. */
13#define VTK_COMPILER_MSVC
14
15#elif defined(__INTEL_COMPILER)
16/* Intel 14+ on OSX uses a clang frontend, so again we want to label them as
17 * intel only, and not intel and clang. */
18#define VTK_COMPILER_ICC
19
20#elif defined(__PGI)
21/* PGI reports as GNUC as it generates the same ABI, so we need to check for
22 * it before gcc. */
23#define VTK_COMPILER_PGI
24
25#elif defined(__clang__)
26/* Check for clang before GCC, as clang says it is GNUC since it has ABI
27 * compliance and supports many of the same extensions. */
28#define VTK_COMPILER_CLANG
29
30#elif defined(__GNUC__)
31/* Several compilers pretend to be GCC but have minor differences. To
32 * compensate for that, we checked for those compilers first above. */
33#define VTK_COMPILER_GCC
34#define VTK_COMPILER_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
35#endif
36
38#define VTK_USE_EXTERN_TEMPLATE
39
40//----------------------------------------------------------------------------
41// Provide a VTK_ALWAYS_EXPORT macro.
42//
43// Issue:
44// Dynamic cast is not just based on the name of the class, but also the
45// combined visibility of the class on macos. When building the hash_code of
46// an object the symbol visibility controls of the type are taken into
47// consideration (including symbol visibility of template parameters).
48// Therefore, if a class has a component with private/hidden visibility then
49// it cannot be passed across library boundaries.
50//
51// Solution:
52// The solution is fairly simple, but annoying. You need to mark template
53// classes intended for use in dynamic_cast with appropriate visibility
54// settings.
55//
56// TL;DR:
57// This markup is used when we want to make sure:
58// - The class can be compiled into multiple libraries and at runtime will
59// resolve to a single type instance
60// - Be a type ( or component of a types signature ) that can be passed between
61// dynamic libraries and requires RTTI support ( dynamic_cast ).
62#if defined(VTK_COMPILER_MSVC)
63#define VTK_ALWAYS_EXPORT
64#else
65#define VTK_ALWAYS_EXPORT __attribute__((visibility("default")))
66#endif
67
68#endif
69
70// VTK-HeaderTest-Exclude: vtkCompiler.h