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