[libcxx-commits] [PATCH] D158214: [libc++] Warn if an unsupported compiler is used

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Aug 17 13:46:23 PDT 2023


philnik created this revision.
Herald added a project: All.
philnik requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This makes it obvious that libc++ is used in an unsupported configuration, and the compiler probably has to be updated. It often happens that people try to use libc++ and don't realize that their compiler is too old.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158214

Files:
  libcxx/include/__config


Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -31,10 +31,26 @@
 #  define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
 #elif defined(__GNUC__)
 #  define _LIBCPP_COMPILER_GCC
+#  define _LIBCPP_GCC_VER (__GNUC__ * 100 + __GNUC_MINOR__)
 #endif
 
 #ifdef __cplusplus
 
+// Warn if a compiler version is used that is not supported anymore
+#  if defined(_LIBCPP_CLANG_VER)
+#    if _LIBCPP_CLANG_VER < 1600
+#      warning "Libc++ only supports Clang 16 and later"
+#    endif
+#  elif defined(_LIBCPP_APPLE_CLANG_VER)
+#    if _LIBCPP_APPLE_CLANG_VER < 1400
+#      warning "Libc++ only supports AppleClang 14 and later"
+#    endif
+#  elif defined(_LIBCPP_GCC_VER)
+#    if _LIBCPP_GCC_VER < 1300
+#      warning "Libc++ only supports GCC 13 and later"
+#    endif
+#  endif
+
 // The attributes supported by clang are documented at https://clang.llvm.org/docs/AttributeReference.html
 
 // _LIBCPP_VERSION represents the version of libc++, which matches the version of LLVM.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158214.551254.patch
Type: text/x-patch
Size: 1105 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230817/dfabf1c1/attachment.bin>


More information about the libcxx-commits mailing list