[libcxx] r305539 - Allow the libc++ C header wrappers to be included when compiling C.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 15 18:57:41 PDT 2017


Author: ericwf
Date: Thu Jun 15 20:57:41 2017
New Revision: 305539

URL: http://llvm.org/viewvc/llvm-project?rev=305539&view=rev
Log:
Allow the libc++ C header wrappers to be included when compiling C.

C99 at least. C89 still fails due to the use of block comments.

NOTE: Having libc++ on the include path when compiling C is not
recommended or ever really supported. However it happens often
enough that this change is warrented.

Added:
    libcxx/trunk/test/libcxx/include_as_c.sh.cpp
Modified:
    libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=305539&r1=305538&r2=305539&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Thu Jun 15 20:57:41 2017
@@ -1135,8 +1135,6 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # define _LIBCPP_HAS_NO_COROUTINES
 #endif
 
-#endif // __cplusplus
-
 // Decide whether to use availability macros.
 #if !defined(_LIBCPP_BUILDING_LIBRARY) &&                                      \
     !defined(_LIBCPP_DISABLE_AVAILABILITY) &&                                  \
@@ -1240,4 +1238,7 @@ _LIBCPP_FUNC_VIS extern "C" void __sanit
 # endif
 #endif // defined(_LIBCPP_HAS_NO_PRAGMA_PUSH_POP_MACRO)
 
+
+#endif // __cplusplus
+
 #endif // _LIBCPP_CONFIG

Added: libcxx/trunk/test/libcxx/include_as_c.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/include_as_c.sh.cpp?rev=305539&view=auto
==============================================================================
--- libcxx/trunk/test/libcxx/include_as_c.sh.cpp (added)
+++ libcxx/trunk/test/libcxx/include_as_c.sh.cpp Thu Jun 15 20:57:41 2017
@@ -0,0 +1,37 @@
+// -*- C++ -*-
+//===----------------------------------------------------------------------===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// Test that the C wrapper headers can be included when compiling them as C.
+
+// NOTE: It's not common or recommended to have libc++ in the header search
+// path when compiling C files, but it does happen often enough.
+
+// RUN: %cxx -c -xc %s -fsyntax-only %flags %compile_flags -std=c99
+
+#include <complex.h>
+#include <ctype.h>
+#include <errno.h>
+#include <float.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <locale.h>
+#include <math.h>
+#include <setjmp.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <tgmath.h>
+#include <wchar.h>
+#include <wctype.h>
+
+int main() {}




More information about the cfe-commits mailing list