FreeRDP
Loading...
Searching...
No Matches
include/freerdp/api.h
1
20#ifndef FREERDP_API_H
21#define FREERDP_API_H
22
23#include <winpr/winpr.h>
24#include <winpr/wlog.h>
25#include <winpr/platform.h>
26
27/* To silence missing prototype warnings for library entry points use this macro.
28 * It first declares the function as prototype and then again as function implementation
29 */
30#define FREERDP_ENTRY_POINT(fkt) \
31 fkt; \
32 fkt
33
34#ifdef _WIN32
35#define FREERDP_CC __cdecl
36#else
37#define FREERDP_CC
38#endif
39
40#if defined _WIN32 || defined __CYGWIN__
41#ifdef FREERDP_EXPORTS
42#ifdef __GNUC__
43#define FREERDP_API __attribute__((dllexport))
44#else
45#define FREERDP_API __declspec(dllexport)
46#endif
47#else
48#ifdef __GNUC__
49#define FREERDP_API __attribute__((dllimport))
50#else
51#define FREERDP_API __declspec(dllimport)
52#endif
53#endif
54#else
55#if defined(__GNUC__) && (__GNUC__ >= 4)
56#if defined(__cplusplus) && (__cplusplus >= 201703L)
57#define FREERDP_API [[gnu::visibility("default")]]
58#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
59#define FREERDP_API [[gnu::visibility("default")]]
60#else
61#define FREERDP_API __attribute__((visibility("default")))
62#endif
63#else
64#define FREERDP_API
65#endif
66#endif
67
68#if defined(EXPORT_ALL_SYMBOLS)
69#define FREERDP_LOCAL FREERDP_API
70#else
71#if defined _WIN32 || defined __CYGWIN__
72#define FREERDP_LOCAL
73#else
74#if defined(__GNUC__) && (__GNUC__ >= 4)
75#if defined(__cplusplus) && (__cplusplus >= 201703L)
76#define FREERDP_LOCAL [[gnu::visibility("hidden")]]
77#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)
78#define FREERDP_LOCAL [[gnu::visibility("hidden")]]
79#else
80#define FREERDP_LOCAL __attribute__((visibility("hidden")))
81#endif
82#else
83#define FREERDP_LOCAL
84#endif
85#endif
86#endif
87
88#define IFCALL(_cb, ...) \
89 do \
90 { \
91 if (_cb != nullptr) \
92 _cb(__VA_ARGS__); \
93 else \
94 WLog_VRB("com.freerdp.api", "IFCALL(" #_cb ") == nullptr"); \
95 } while (0)
96#define IFCALLRET(_cb, _ret, ...) \
97 do \
98 { \
99 if (_cb != nullptr) \
100 _ret = _cb(__VA_ARGS__); \
101 else \
102 WLog_VRB("com.freerdp.api", "IFCALLRET(" #_cb ") == nullptr"); \
103 } while (0)
104
105#if defined(__GNUC__) || defined(__clang__)
106#define IFCALLRESULT(_default_return, _cb, ...) \
107 __extension__({ \
108 if (_cb == nullptr) \
109 { \
110 WLog_VRB("com.freerdp.api", "IFCALLRESULT(" #_cb ") == nullptr"); \
111 } \
112 ((_cb != nullptr) ? _cb(__VA_ARGS__) : (_default_return)); \
113 })
114#else
115#define IFCALLRESULT(_default_return, _cb, ...) \
116 ((_cb != nullptr) ? _cb(__VA_ARGS__) : (_default_return))
117#endif
118
119#define ALIGN64 DECLSPEC_ALIGN(8)
120
121#endif /* FREERDP_API */