FLTK 1.4.0
Loading...
Searching...
No Matches
fl_attr.h
Go to the documentation of this file.
1/*
2 * Function attribute declarations for the Fast Light Tool Kit (FLTK).
3 *
4 * Copyright 1998-2023 by Bill Spitzak and others.
5 *
6 * This library is free software. Distribution and use rights are outlined in
7 * the file "COPYING" which should have been included with this file. If this
8 * file is missing or damaged, see the license at:
9 *
10 * https://www.fltk.org/COPYING.php
11 *
12 * Please see the following page on how to report bugs and issues:
13 *
14 * https://www.fltk.org/bugs.php
15 */
16
22#ifndef _FL_fl_attr_h_
23#define _FL_fl_attr_h_
24
25
31#ifdef FL_DOXYGEN
32
33
40#define __fl_attr(x)
41
46#define FL_OVERRIDE override
47
57#define FL_DEPRECATED(msg, func) \
58 /##*##* \deprecated msg *##/ \
59 func
60
61
62#else /* FL_DOXYGEN */
63
64#ifdef __cplusplus
65
66/*
67 Declare macros specific to Visual Studio.
68
69 Visual Studio defines __cplusplus = '199711L' in all its versions which is
70 not helpful for us here. For VS version number encoding see:
71 https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
72
73 This document specifies that the macro _MSVC_LANG is defined since
74 "Visual Studio 2015 Update 3" as 201402L (default) and undefined in
75 earlier versions. It can be used to determine the C++ standard as
76 specified by the /std:c++ compiler option:
77
78 - /std:c++14 201402L (also if /std:c++ is not used)
79 - /std:c++17 201703L
80 - /std:c++20 202002L
81 - /std:c++latest a "higher, unspecified value" (docs of VS 2022)
82
83 As of this writing (02/2023) _MSVC_LANG is not yet used in this file
84 but it is documented for future use.
85*/
86
87#if defined(_MSC_VER)
88
89#if (_MSC_VER >= 1900) // Visual Studio 2015 (14.0)
90#ifndef FL_OVERRIDE
91#define FL_OVERRIDE override
92#endif
93#endif // Visual Studio 2015 (14.0)
94
95#if (_MSC_VER >= 1400) // Visual Studio 2005 (8.0)
96#ifndef FL_DEPRECATED
97#define FL_DEPRECATED(msg, func) __declspec(deprecated(msg)) func
98#endif
99#endif // Visual Studio 2005 (8.0)
100
101#if (_MSC_VER >= 1310) // Visual Studio .NET 2003 (7.1)
102#ifndef FL_DEPRECATED
103#define FL_DEPRECATED(msg, func) __declspec(deprecated) func
104#endif
105#endif // Visual Studio .NET 2003 (7.1)
106
107#endif // Visual Studio
108
109
110/*
111 Declare macros specific to the C++ standard used.
112
113 Macros may have been declared already in previous sections.
114 */
115#if (__cplusplus >= 202002L) // C++20
116#endif // C++20
117
118#if (__cplusplus >= 201703L) // C++17
119#endif // C++17
120
121#if (__cplusplus >= 201402L) // C++14
122#ifndef FL_DEPRECATED
123#define FL_DEPRECATED(msg, func) [[deprecated(msg)]] func
124#endif
125#endif // C++14
126
127#if (__cplusplus >= 201103L) // C++11
128#ifndef FL_OVERRIDE
129#define FL_OVERRIDE override
130#endif
131#endif // C+11
132
133#if (__cplusplus >= 199711L) // C++89
134#endif // C++89
135
136#endif // __cplusplus
137
138/*
139 Declare macros specific to clang
140
141 Macros may have been declared already in previous sections.
142 */
143#if defined(__clang__)
144
145#define FL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
146
147// -- nothing yet --
148
149#endif // __clang__
150
151
152/*
153 Declare macros specific to gcc.
154
155 Macros may have been declared already in previous sections.
156 */
157#if defined(__GNUC__)
158
159#define FL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
160
161#ifndef __fl_attr
162#define __fl_attr(x) __attribute__ (x)
163#endif
164
165#if FL_GCC_VERSION > 40500 // gcc 4.5.0
166#ifndef FL_DEPRECATED
167#define FL_DEPRECATED(msg, func) func __attribute__((deprecated(msg)))
168#endif
169#endif // gcc 4.5.0
170
171#if FL_GCC_VERSION > 30100 // gcc 3.1.0
172#ifndef FL_DEPRECATED
173#define FL_DEPRECATED(msg, func) func __attribute__((deprecated))
174#endif
175#endif // gcc 3.1.0
176
177#endif // __GNUC__
178
179
180/*
181 If a macro was not defined in any of the sections above, set it to no-op here.
182 */
183
184#ifndef __fl_attr
185#define __fl_attr(x)
186#endif
187
188#ifndef FL_OVERRIDE
189#define FL_OVERRIDE
190#endif
191
192#ifndef FL_DEPRECATED
193#define FL_DEPRECATED(msg, func) func
194#endif
195
196
197#endif /* FL_DOXYGEN */
198
199
200#endif /* !_FL_fl_attr_h_ */