44 lines · c
1//===-- Compile time compiler detection -------------------------*- C++ -*-===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H10#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H11 12// Example usage of compiler version checks13// #if defined(LIBC_COMPILER_CLANG_VER)14// # if LIBC_COMPILER_CLANG_VER < 150015// # warning "Libc only supports Clang 15 and later"16// # endif17// #elif defined(LIBC_COMPILER_GCC_VER)18// # if LIBC_COMPILER_GCC_VER < 150019// # warning "Libc only supports GCC 15 and later"20// # endif21// #elif defined(LIBC_COMPILER_MSC_VER)22// # if LIBC_COMPILER_MSC_VER < 193023// # warning "Libc only supports Visual Studio 2022 RTW (17.0) and later"24// # endif25// #endif26 27#if defined(__clang__)28#define LIBC_COMPILER_IS_CLANG29#define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)30#endif31 32#if defined(__GNUC__) && !defined(__clang__)33#define LIBC_COMPILER_IS_GCC34#define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)35#endif36 37#if defined(_MSC_VER) && !defined(__clang__)38#define LIBC_COMPILER_IS_MSVC39// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros40#define LIBC_COMPILER_MSVC_VER (_MSC_VER)41#endif42 43#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H44