summaryrefslogtreecommitdiff
path: root/FL/fl_attr.h
blob: 44a402c776858544c688ab9e22863e691eb551b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * Function attribute declarations for the Fast Light Tool Kit (FLTK).
 *
 * Copyright 1998-2023 by Bill Spitzak and others.
 *
 * This library is free software. Distribution and use rights are outlined in
 * the file "COPYING" which should have been included with this file.  If this
 * file is missing or damaged, see the license at:
 *
 *     https://www.fltk.org/COPYING.php
 *
 * Please see the following page on how to report bugs and issues:
 *
 *     https://www.fltk.org/bugs.php
 */

/**
 \file fl_attr.h
 This file defines compiler-specific macros
*/

#ifndef _FL_fl_attr_h_
#define _FL_fl_attr_h_

#ifdef FL_DOXYGEN

/**
  This macro makes it safe to use the C++11 keyword \c override with
  older compilers.
*/
#define FL_OVERRIDE override

/** To be used in prototypes with a variable list of arguments.
 This macro helps detection of mismatches between format string and
 argument list at compilation time.
 
 Usage example: FL/fl_ask.H
 */
#define __fl_attr(x)

#else


/*
  The GNUC-specific attribute appearing below in prototypes with a variable
  list of arguments helps detection of mismatches between format string and
  argument list at compilation time.

  Examples: see fl_ask.H
*/

#ifdef __GNUC__
#  define __fl_attr(x) __attribute__ (x)
#else
#  define __fl_attr(x)
#endif


#ifdef __cplusplus

// Visual Studio defines __cplusplus = '199711L' which is not helpful.
// We assume that Visual Studio 2015 (1900) and later support the
// 'override' keyword. For VS version number encoding see:
// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros

#if defined(_MSC_VER) && (_MSC_VER >= 1900)

#define FL_OVERRIDE override

#else // not Visual Studio or an older version

#if (__cplusplus >= 202002L)
// put here definitions applying to C++20 and above
#endif

#if (__cplusplus >= 201703L)
// put here definitions applying to C++17 and above
#endif

#if (__cplusplus >= 201402L)
// put here definitions applying to C++14 and above
#endif

#if (__cplusplus >= 201103L)
// put here definitions applying to C++11 and above
#define FL_OVERRIDE override
#else
// replace non-existing `override` with no-op
#define FL_OVERRIDE
#endif

#if (__cplusplus >= 199711L)
// put here definitions applying to C++98 and above
#endif

#endif /* not Visual Studio */

#else
/* C, not C++ */

#endif /* __cplusplus */

#endif /* FL_DOXYGEN */


#endif /* !_FL_fl_attr_h_ */