[PATCH] D105439: [clang] protects users from relying on libc++ detail headers

Arthur O'Dwyer via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 5 10:25:23 PDT 2021


Quuxplusone added a comment.

I should add that if any particular library really wants to //enforce// "thou shalt not deep-link <https://en.wikipedia.org/wiki/Deep_linking> detail headers" (instead of just documenting it and/or relying on the user-programmer's common sense) they can do it pretty cleanly via macros:

  // toplevel.h
  #pragma once
  #define DONT_INCLUDE_DETAIL_HEADERS_DIRECTLY(x, y)
  #include <__utility/foo.h>
  #include <__various/bar.h>
  #undef DONT_INCLUDE_DETAIL_HEADERS_DIRECTLY
  // more code here

and then

  // __utility/foo.h
  #pragma once
  DONT_INCLUDE_DETAIL_HEADERS_DIRECTLY(instead, include <utility>)
  class Foo {};
  void foo();

I don't know how you'd achieve a similar effect with C++20 Modules, but I certainly hope it's possible somehow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105439/new/

https://reviews.llvm.org/D105439



More information about the cfe-commits mailing list