title: Is it possible to subclass a C struct in C++ and use pointers to the struct in C code?
body: <p>Is there a side effect in doing this:</p>
  
  <p>C code:</p>
  
  <pre><code>struct foo {
        int k;
  };
  
  int ret_foo(const struct foo* f){ 
      return f.k; 
  }
  </code></pre>
  
  <p>C++ code:</p>
  
  <pre><code>class bar : public foo {
  
     int my_bar() { 
         return ret_foo( (foo)this ); 
     }
  
  };
  </code></pre>
  
  <p>There's an <code>extern "C"</code> around the C++ code and each code is inside its own compilation unit.</p>
  
  <p>Is this portable across compilers?</p>