45 lines · c
1/*===-- llvm-c/Visibility.h - Visibility macros for llvm-c ------*- C++ -*-===*\2|* *|3|* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|4|* Exceptions. *|5|* See https://llvm.org/LICENSE.txt for license information. *|6|* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|7|* *|8|*===----------------------------------------------------------------------===*|9|* *|10|* This header defines visibility macros used for the LLVM C interface. These *|11|* macros are used to annotate C functions that should be exported as part of *|12|* a shared library or DLL. *|13|* *|14\*===----------------------------------------------------------------------===*/15 16#ifndef LLVM_C_VISIBILITY_H17#define LLVM_C_VISIBILITY_H18 19#include "llvm/Config/llvm-config.h"20 21/// LLVM_C_ABI is the export/visibility macro used to mark symbols declared in22/// llvm-c as exported when built as a shared library.23 24#if !defined(LLVM_ABI_GENERATING_ANNOTATIONS)25// TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for26// two preprocessor definitions to gate LLVM_ABI macro definitions.27#if defined(LLVM_ENABLE_LLVM_C_EXPORT_ANNOTATIONS) && \28 !defined(LLVM_BUILD_STATIC)29#if defined(_WIN32) && !defined(__MINGW32__)30#if defined(LLVM_EXPORTS)31#define LLVM_C_ABI __declspec(dllexport)32#else33#define LLVM_C_ABI __declspec(dllimport)34#endif35#elif defined(__has_attribute) && __has_attribute(visibility)36#define LLVM_C_ABI __attribute__((visibility("default")))37#endif38#endif39#if !defined(LLVM_C_ABI)40#define LLVM_C_ABI41#endif42#endif43 44#endif45