1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 21:47:45 +00:00

AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most places

Doesn't use them in libc headers so that those don't have to pull in
AK/Platform.h.

AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is
defined in clang builds as well.) Using AK_COMPILER_GCC simplifies
things some.

AK_COMPILER_CLANG isn't as much of a win, other than that it's
consistent with AK_COMPILER_GCC.
This commit is contained in:
Nico Weber 2022-10-04 15:04:13 -04:00 committed by Linus Groh
parent ff4b912b7c
commit 2af028132a
35 changed files with 64 additions and 49 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2022, Nico Weber <thakis@chromium.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -24,6 +25,12 @@
# define AK_ARCH_32_BIT
#endif
#if defined(__clang__)
# define AK_COMPILER_CLANG
#elif defined(__GNUC__)
# define AK_COMPILER_GCC
#endif
#if defined(__serenity__)
# define AK_OS_SERENITY
#endif
@ -84,7 +91,7 @@
# define VALIDATE_IS_X86() static_assert(false, "Trying to include x86 only header on non x86 platform");
#endif
#if !defined(__clang__) && !defined(__CLION_IDE_) && !defined(__CLION_IDE__)
#if !defined(AK_COMPILER_CLANG) && !defined(__CLION_IDE_) && !defined(__CLION_IDE__)
# define AK_HAS_CONDITIONALLY_TRIVIAL
#endif
@ -121,7 +128,7 @@
#ifdef DISALLOW
# undef DISALLOW
#endif
#ifdef __clang__
#if defined(AK_COMPILER_CLANG)
# define DISALLOW(message) __attribute__((diagnose_if(1, message, "error")))
#else
# define DISALLOW(message) __attribute__((error(message)))