<p dir="auto">by <strong><a href="mailto:mazdak@chango.com">mazdak@chango.com</a></strong>:</p>
<pre class="notranslate">On OS X 10.9 Mavericks, when building the following code snippet, I get the following
error:

# command-line-arguments
xxxx.go:190:12: struct size calculation error off=40 bytesize=32

The same go file (which is actually a cgo file) works on older versions of OS X and
Linux.

To assist, here is a snippet that reproduces the above problem:

----------

package main

/*

#include &lt;stdlib.h&gt;

enum ct { A = 0x00, B = 0x01};
typedef enum ct ct;

typedef struct cobject_s {
  enum ct    type;
  size_t      sz;
  union {
    char    *str; // note for str: sz is strlen (not strlen+1
    void    *blob;
    int64_t   i64;   // easiest to have one large int type
  } u;

  void *free; // if this is set, this must be freed on destructuion

} cobject;


typedef struct cbin_s {
  char    bin_name[32];
  cobject object;
} cbin;

*/
import "C"

func main() {
    var a C.cbin
}</pre>
<pre class="notranslate"><a href="http://play.golang.org/p/FYbJS-dtlY" rel="nofollow">http://play.golang.org/p/FYbJS-dtlY</a>

If one gets variable names confused and accidentally take the index of an integer type,
the error returned is "index of type int". This error makes it sound like the
index variable is of integer type, which is correct code. I think it would be much
better if it read "taking index of type int". This makes it clear that the
error refers to the type having its index taken, and not the type of the index variable
itself.</pre>