aboutsummaryrefslogtreecommitdiff
path: root/lib/libcxx/libc/src/__support/macros/properties/compiler.h
blob: b9ec0dd1defb9df0dbe58d58f93db4cfe2139b96 (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
//===-- Compile time compiler detection -------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H
#define LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H

// Example usage of compiler version checks
// #if defined(LIBC_COMPILER_CLANG_VER)
// #  if LIBC_COMPILER_CLANG_VER < 1500
// #    warning "Libc only supports Clang 15 and later"
// #  endif
// #elif defined(LIBC_COMPILER_GCC_VER)
// #  if LIBC_COMPILER_GCC_VER < 1500
// #    warning "Libc only supports GCC 15 and later"
// #  endif
// #elif defined(LIBC_COMPILER_MSC_VER)
// #  if LIBC_COMPILER_MSC_VER < 1930
// #    warning "Libc only supports Visual Studio 2022 RTW (17.0) and later"
// #  endif
// #endif

#if defined(__clang__)
#define LIBC_COMPILER_IS_CLANG
#define LIBC_COMPILER_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
#endif

#if defined(__GNUC__) && !defined(__clang__)
#define LIBC_COMPILER_IS_GCC
#define LIBC_COMPILER_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
#endif

#if defined(_MSC_VER)
#define LIBC_COMPILER_IS_MSC
// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros
#define LIBC_COMPILER_MSC_VER (_MSC_VER)
#endif

#endif // LLVM_LIBC_SRC___SUPPORT_MACROS_PROPERTIES_COMPILER_H