diff options
| author | Matthias Melcher <github@matthiasm.com> | 2022-12-30 19:14:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-12-30 19:14:36 +0100 |
| commit | 44c874b731f9f58c2f50c3c6076371058cbe26e3 (patch) | |
| tree | 2386dfcc700c41a1109fc78b96875c11056abcc9 /FL/fl_attr.h | |
| parent | f58a93a159105336136ce6e54ab7fc161e4fa15a (diff) | |
Use `FL_OVERRIDE` for all overridden virtual methods (#611)
FL_OVERRIDE is defined as `override` for C++11 and higher
FL_OVERRIDE is defined as `override` for VisualC 2015 and newer
Don't interfere with Fl_Widget::override()
Diffstat (limited to 'FL/fl_attr.h')
| -rw-r--r-- | FL/fl_attr.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/FL/fl_attr.h b/FL/fl_attr.h index 32e88a2a4..e2d6961da 100644 --- a/FL/fl_attr.h +++ b/FL/fl_attr.h @@ -31,4 +31,62 @@ # define __fl_attr(x) #endif + +#ifdef FL_DOXYGEN + +/** + This macro makes it safe to use the C++11 keyword \c override with + older compilers. +*/ +#define FL_OVERRIDE override + +#else + +#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_ */ |
