cstdio: limit gets to CRT versions below 14
Microsoft removed gets from the CRT in Visual Studio 2015 onwards [1].
Attempting to reference it when targeting CRT versions 14 and above will cause
compile errors.
[1] https://msdn.microsoft.com/en-us/library/2029ea5f.aspx
Patch by Shoaib Meenai!
llvm-svn: 280417
Cr-Mirrored-From: sso://chromium.googlesource.com/_direct/external/github.com/llvm/llvm-project
Cr-Mirrored-Commit: e68b47070f617ffa8becd3c9d777a93cf2c3b6a8
diff --git a/include/cstdio b/include/cstdio
index 50fdd34..8013488 100644
--- a/include/cstdio
+++ b/include/cstdio
@@ -98,6 +98,9 @@
#include <__config>
#include <stdio.h>
+#if defined(_LIBCPP_MSVCRT)
+#include <crtversion.h>
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header
@@ -155,7 +158,8 @@
#ifndef _LIBCPP_HAS_NO_STDIN
using ::getchar;
-#if _LIBCPP_STD_VER <= 11
+#if _LIBCPP_STD_VER <= 11 && \
+ (!defined(_VC_CRT_MAJOR_VERSION) || _VC_CRT_MAJOR_VERSION < 14)
using ::gets;
#endif
using ::scanf;