[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

Andrey Khalyavin via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 23 21:39:12 PDT 2017


halyavin added a comment.

Here is how we solved this problem in our libc++ fork:

  #define _LIBCPP_UCRT_INCLUDE(x) <../ucrt/x>
  #define _LIBCPP_MSVC_INCLUDE(x) <../../VC/include/x>



  #ifdef _LIBCPP_COMPILER_MSVC
  #include _LIBCPP_UCRT_INCLUDE(wchar.h)
  #else
  #include_next <wchar.h>
  #endif

As far as I understand neither solution resolves the problem with original paths not excluded. Watch out for cycling dependencies created by MSVC includes using other includes which point right back to libc++ instead.

Also, there is a problem with errno macro. I solved it like this:

  #ifdef _LIBCPP_COMPILER_MSVC
  // errno is defined in several files so we can't use #ifndef errno here
  #ifdef errno
  // undefine errno to avoid substitution in errno.h include file name.
  #pragma push_macro("errno")
  #undef errno
  #include _LIBCPP_UCRT_INCLUDE(errno.h)
  #pragma pop_macro("errno")
  #else
  #include _LIBCPP_UCRT_INCLUDE(errno.h)
  #endif
  #else
  #include_next <errno.h>
  #endif


https://reviews.llvm.org/D32411





More information about the cfe-commits mailing list