title: Is it possible to write C functions that modify structs of types defined in Go code?
body: <p><em>This is a follow-up to <a href="https://stackoverflow.com/questions/23919677/marshalling-c-objects-that-cannot-be-accessed-from-go">this question</a>. I made an assumption there that might not be true, which is why I am explicitly asking about it. Because I forgot to ask if this is actually possible, I have already filed <a href="https://code.google.com/p/go/issues/detail?id=8114" rel="nofollow noreferrer">issue #8114</a> about this.</em></p>
  
  <hr>
  
  <p>With cgo, it is possible to have Go code operate on C types, like this:</p>
  
  <pre><code>package foo
  
  //#include &lt;sys/stat.h&gt;
  import "C"
  
  func fileSizeFromStat(stat *C.struct_stat) int64 {
      return int64(stat.st_size)
  }
  </code></pre>
  
  <p>Is the reverse possible? I.e. writing C functions that operate on go types? The concrete point of this is outlined in the question linked above; I want to marshall C structures that cannot be accessed from Go code, either because they use unions or bitfields or because their alignment makes them incompatible with Go code.</p>