LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
visibility.h
1/*
2 * Copyright 2026 LiveKit
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19// LIVEKIT_API marks a symbol as part of the public ABI of liblivekit.
20//
21// On Unix, the SDK is built with -fvisibility=hidden / -fvisibility-inlines-hidden,
22// so every symbol defaults to hidden. LIVEKIT_API re-exposes the symbol with
23// default visibility. Consumers also need default visibility so public RTTI
24// stays unique across shared-library boundaries.
25//
26// On Windows, the SDK is built without WINDOWS_EXPORT_ALL_SYMBOLS, so symbols
27// must be explicitly tagged with __declspec(dllexport) when building the SDK
28// and __declspec(dllimport) when consuming it. LIVEKIT_BUILDING_SDK is defined
29// only when compiling the SDK itself (set in CMakeLists.txt).
30
31#if defined(_WIN32)
32#if defined(LIVEKIT_BUILDING_SDK)
33#define LIVEKIT_API __declspec(dllexport)
34#else
35#define LIVEKIT_API __declspec(dllimport)
36#endif
37#else
38#define LIVEKIT_API __attribute__((visibility("default")))
39#endif
40
41// LIVEKIT_INTERNAL_API marks a symbol that is NOT part of the public ABI but
42// must remain visible so that the in-tree test binaries (which link against
43// the same shared library) can resolve it.
44//
45// External consumers must not rely on LIVEKIT_INTERNAL_API symbols; they may
46// change or disappear without notice.
47//
48// On Windows, internal symbols are exported the same way as public ones
49// because tests link via the standard import library; on Unix, hidden
50// visibility is overridden for these specific symbols only.
51
52#if defined(_WIN32)
53#define LIVEKIT_INTERNAL_API LIVEKIT_API
54#else
55#if defined(LIVEKIT_BUILDING_SDK)
56#define LIVEKIT_INTERNAL_API __attribute__((visibility("default")))
57#else
58#define LIVEKIT_INTERNAL_API
59#endif
60#endif