title: How to get offsetof() a private class-member?
body: <p>I have a C++ class (<code>Scenario</code>) wrapped in a Python type:</p>
  
  <pre><code>struct PyScenario {
      PyObject_HEAD
      Scenario scen;
  };
  </code></pre>
  
  <p>I'd like to expose some of the private members of <code>Scenario</code> to Python scripts -- without using the explicit getter/setter functions:</p>
  
  <pre><code>static PyMemberDef scenarioMembers[] {
      {
          (char *)"a",
          T_DOUBLE, offsetof(PyScenario, scen._a),
          "The a"
      },
      {
          (char *)"b",
          T_INT, offsetof(PyScenario, scen._b),
          "The b"
      },
      NULL
  };
  </code></pre>
  
  <p>Unfortunately, when I compile the above, I get an error like: <code>'double Scenario::_a' is private within this context</code>.</p>
  
  <p>I don't want to make the <code>_a</code> and <code>_b</code> public, so I tried declaring the <code>PyMemberDef</code> a <code>friend</code> of <code>Scenario</code>:</p>
  
  <pre><code>class Scenario {
  #ifdef PY_MAJOR_VERSION
      friend   struct PyMemberDef;
  #endif
  private:
      double   _a;
      int      _b;
      ....
  };
  </code></pre>
  
  <p>Unfortunately, that didn't help... What's the right way?</p>