diff --git a/acinclude.m4 b/acinclude.m4 index 4c6b2e26..35a5935a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -334,9 +334,3 @@ AH_BOTTOM([#if C_ATTRIBUTE_FASTCALL #else #define DB_FASTCALL #endif]) - -AH_BOTTOM([#if C_HAS_ATTRIBUTE -#define GCC_ATTRIBUTE(x) __attribute__ ((x)) -#else -#define GCC_ATTRIBUTE(x) /* attribute not supported */ -#endif]) diff --git a/include/compiler.h b/include/compiler.h index 641ee5eb..384f8dc5 100644 --- a/include/compiler.h +++ b/include/compiler.h @@ -22,6 +22,25 @@ // This header wraps compiler-specific features, so they won't need to // be hacked into the buildsystem. +// Modern C++ compilers have better support for feature testing using GNU +// extension __has_attribute but C++20 introduces even better alternative: +// standard-defined __has_cpp_attribute, which will remove the need for +// defining C_HAS_* macros on a buildsystem level (at some point). + +// The __attribute__ syntax is supported by GCC, Clang, and IBM compilers. +// +// TODO: C++11 introduces standard syntax for implementation-defined attributes, +// it should allow for removal of C_HAS_ATTRIBUTE from the buildsystem. +// However, the vast majority of GCC_ATTRIBUTEs in DOSBox code need +// to be reviewed, as many of them seem to be incorrectly/unnecessarily +// used. + +#if C_HAS_ATTRIBUTE +#define GCC_ATTRIBUTE(x) __attribute__ ((x)) +#else +#define GCC_ATTRIBUTE(x) /* attribute not supported */ +#endif + // GCC_LIKELY macro is incorrectly named, because other compilers support // this feature as well (e.g. Clang, Intel); leave it be for now, at // least until full support for C++20 [[likely]] attribute will start arriving diff --git a/src/platform/visualc/config.h b/src/platform/visualc/config.h index e1ae2283..ce2ea5b5 100644 --- a/src/platform/visualc/config.h +++ b/src/platform/visualc/config.h @@ -63,8 +63,6 @@ /* Define to 1 if you want serial passthrough support. */ #define C_DIRECTSERIAL 1 -#define GCC_ATTRIBUTE(x) /* attribute not supported */ - #define INLINE __forceinline #define DB_FASTCALL __fastcall