FLTK 1.5.0
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-2025 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
38#define FL_OVERRIDE override
39
40
46#ifdef FL_DOXYGEN
47
48
55#define __fl_attr(x)
56
57
67#define FL_DEPRECATED(msg, func) \
68 /##*##* \deprecated msg *##/ \
69 func
70
71
72#else /* FL_DOXYGEN */
73
74// If FL_NO_DEPRECATED is defined FLTK 1.4 can compile 1.3.x code without
75// issuing several "deprecated" warnings (1.3 "compatibility" mode).
76// FL_DEPRECATED will be defined as a no-op.
77
78// If FL_NO_DEPRECATED is not defined (default) FLTK 1.4 will issue several
79// "deprecated" warnings depending on the compiler in use: FL_DEPRECATED
80// will be defined according to the capabilities of the compiler (below).
81// The definition below this comment must match the one at the end of this file.
82
83#if defined(FL_NO_DEPRECATED)
84#define FL_DEPRECATED(msg, func) func
85#endif
86
87#ifdef __cplusplus
88
89/*
90 Declare macros specific to Visual Studio.
91
92 Visual Studio defines __cplusplus = '199711L' in all its versions which is
93 not helpful for us here. For VS version number encoding see:
94 https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
95
96 This document specifies that the macro _MSVC_LANG is defined since
97 "Visual Studio 2015 Update 3" as 201402L (default) and undefined in
98 earlier versions. It can be used to determine the C++ standard as
99 specified by the /std:c++ compiler option:
100
101 - /std:c++14 201402L (also if /std:c++ is not used)
102 - /std:c++17 201703L
103 - /std:c++20 202002L
104 - /std:c++latest a "higher, unspecified value" (docs of VS 2022)
105
106 As of this writing (02/2023) _MSVC_LANG is not yet used in this file
107 but it is documented for future use.
108*/
109
110#if defined(_MSC_VER)
111
112#if (_MSC_VER >= 1900) // Visual Studio 2015 (14.0)
113#endif // Visual Studio 2015 (14.0)
114
115#if (_MSC_VER >= 1400) // Visual Studio 2005 (8.0)
116#ifndef FL_DEPRECATED
117#define FL_DEPRECATED(msg, func) __declspec(deprecated(msg)) func
118#endif
119#endif // Visual Studio 2005 (8.0)
120
121#if (_MSC_VER >= 1310) // Visual Studio .NET 2003 (7.1)
122#ifndef FL_DEPRECATED
123#define FL_DEPRECATED(msg, func) __declspec(deprecated) func
124#endif
125#endif // Visual Studio .NET 2003 (7.1)
126
127#endif // Visual Studio
128
129
130/*
131 Declare macros specific to the C++ standard used.
132
133 Macros may have been declared already in previous sections.
134 */
135#if (__cplusplus >= 202002L) // C++20
136#endif // C++20
137
138#if (__cplusplus >= 201703L) // C++17
139#endif // C++17
140
141#if (__cplusplus >= 201402L) // C++14
142#ifndef FL_DEPRECATED
143#define FL_DEPRECATED(msg, func) [[deprecated(msg)]] func
144#endif
145#endif // C++14
146
147#if (__cplusplus >= 201103L) // C++11
148#endif // C+11
149
150#if (__cplusplus >= 199711L) // C++89
151#endif // C++89
152
153#endif // __cplusplus
154
155/*
156 Declare macros specific to clang
157
158 Macros may have been declared already in previous sections.
159 */
160#if defined(__clang__)
161
162#define FL_CLANG_VERSION (__clang_major__ * 10000 + __clang_minor__ * 100 + __clang_patchlevel__)
163
164// -- nothing yet --
165
166#endif /* __clang__ */
167
168
169/*
170 Declare macros specific to gcc.
171
172 Macros may have been declared already in previous sections.
173 */
174#if defined(__GNUC__)
175
176#define FL_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
177
178#ifndef __fl_attr
179#define __fl_attr(x) __attribute__ (x)
180#endif
181
182#if FL_GCC_VERSION > 40500 /* gcc 4.5.0 */
183#ifndef FL_DEPRECATED
184#define FL_DEPRECATED(msg, func) func __attribute__((deprecated(msg)))
185#endif
186#endif /* gcc 4.5.0 */
187
188#if FL_GCC_VERSION >= 30400 /* gcc 3.4.0 */
189#ifndef FL_DEPRECATED
190#define FL_DEPRECATED(msg, func) func __attribute__((deprecated))
191#endif
192#endif /* gcc 3.4.0 */
193
194#endif /* __GNUC__ */
195
196
197/*
198 If a macro was not defined in any of the sections above, set it to no-op here.
199 */
200
201#ifndef __fl_attr
202#define __fl_attr(x)
203#endif
204
205#ifndef FL_DEPRECATED
206#define FL_DEPRECATED(msg, func) func
207#endif
208
209
210#endif /* FL_DOXYGEN */
211
212
213#endif /* !_FL_fl_attr_h_ */