title: Protecting the rest of the world from system headers
body: <p>Good day!</p>
  
  <p>I am currently looking for "the" way to protect the rest of the program from system dependent header files. One often is unable to just put it in a detail namespace, due to dependencies of the system header itself. My consideration was now to use extern declared variables inside a detail namespace and give them a value inside a .cpp file which includes the system headers. This appeared to be the perfect solution, since the outer world doesn't even know most of the stuff, and all you need can be packed in a detail namespace. But there is one problem: You can not initialize enum constants with extern constants.</p>
  
  <p>My question: Is there any way to use enum/struct types with extern variables? Or is there even a better way to protect the program from system headers?</p>
  
  <p>VS11 says:</p>
  
  <pre><code>namespace detail
  {
    extern const int value;
  }
  
  const auto val = detail::value; // ok
  
  enum class my_enum
  {
    value = detail::value, // "expression must have a constant value"
  };
  
  struct my_struct
  {
    static const auto value = detail::value; // "constant value is not known"
  };
  </code></pre>