nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
include
nros
visibility.h
Go to the documentation of this file.
1
11
#ifndef NROS_VISIBILITY_H
12
#define NROS_VISIBILITY_H
13
14
#ifdef __cplusplus
15
extern
"C"
{
16
#endif
17
18
// Visibility macros for shared library support
19
#if defined(_WIN32)
20
#if defined(NROS_BUILDING_DLL)
21
#define NROS_PUBLIC __declspec(dllexport)
22
#elif defined(NROS_USING_DLL)
23
#define NROS_PUBLIC __declspec(dllimport)
24
#else
25
#define NROS_PUBLIC
26
#endif
27
#define NROS_LOCAL
28
#else
29
#if __GNUC__ >= 4
30
#define NROS_PUBLIC __attribute__((visibility("default")))
31
#define NROS_LOCAL __attribute__((visibility("hidden")))
32
#else
33
#define NROS_PUBLIC
34
#define NROS_LOCAL
35
#endif
36
#endif
37
38
// Deprecation macros.
39
//
40
// NROS_DEPRECATED marks an item without saying what to use instead;
41
// NROS_DEPRECATED_MSG(msg) carries the migration target into the compiler's
42
// diagnostic, which is the difference between a warning a user can act on and
43
// one they can only silence. Prefer the _MSG form for a renamed entry point.
44
//
45
// Both attach to a FUNCTION or an OBJECT. C has no portable way to deprecate a
46
// `typedef` -- GCC/Clang accept the attribute there but MSVC does not, and no C
47
// standard before C23 has `[[deprecated]]` -- so a renamed TYPE gets a plain
48
// alias and a comment, never one of these macros. Do not pretend a typedef
49
// warns.
50
#if defined(__GNUC__) || defined(__clang__)
51
#define NROS_DEPRECATED __attribute__((deprecated))
52
#define NROS_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
53
#elif defined(_MSC_VER)
54
#define NROS_DEPRECATED __declspec(deprecated)
55
#define NROS_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
56
#else
57
#define NROS_DEPRECATED
58
#define NROS_DEPRECATED_MSG(msg)
59
#endif
60
61
// Warn unused result
62
#if defined(__GNUC__) || defined(__clang__)
63
#define NROS_WARN_UNUSED __attribute__((warn_unused_result))
64
#else
65
#define NROS_WARN_UNUSED
66
#endif
67
68
#ifdef __cplusplus
69
}
70
#endif
71
72
#endif
// NROS_VISIBILITY_H
Generated by
1.9.8