[libcxx] r280417 - cstdio: limit gets to CRT versions below 14

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 1 14:09:19 PDT 2016


Author: compnerd
Date: Thu Sep  1 16:09:19 2016
New Revision: 280417

URL: http://llvm.org/viewvc/llvm-project?rev=280417&view=rev
Log:
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!

Modified:
    libcxx/trunk/include/cstdio

Modified: libcxx/trunk/include/cstdio
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=280417&r1=280416&r2=280417&view=diff
==============================================================================
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/cstdio Thu Sep  1 16:09:19 2016
@@ -98,6 +98,9 @@ void perror(const char* s);
 
 #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 @@ using ::tmpnam;
 
 #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;




More information about the cfe-commits mailing list