Skip to content

cmd/cgo: mysterious missing typedef[...] definition on Mac OS X handling internal Objective-C types #8238

Closed
@andlabs

Description

@andlabs
from src/cmd/cgo/gcc.go:
  1286              if isStructUnionClass(sub.Go) {
  1287                  // Use the typedef name for C code.
  1288                  typedef[sub.Go.(*ast.Ident).Name].C = t.C
  1289              }

When handling one of Objective-C's internal types, go get github.com/andlabs/ui fails
with a nil pointer dereference panic at line 1288 above. Upon further investigation:

### sub.Go:&ast.Ident{NamePos:0, Name:"_Ctype_struct_objc_object",
Obj:(*ast.Object)(nil)} sub.Go.(*ast.Ident):&ast.Ident{NamePos:0,
Name:"_Ctype_struct_objc_object", Obj:(*ast.Object)(nil)}
....Name:"_Ctype_struct_objc_object"
typedef:map[string]*main.Type{"_Ctype_struct_objc_cache":(*main.Type)(0x2083eacc0),
"_Ctype_int":(*main.Type)(0x2084d7480),
"_Ctype_struct_objc_method_list":(*main.Type)(0x2084d7e00),
"_Ctype_SEL":(*main.Type)(0x2084d7b00),
"_Ctype_Class":(*main.Type)(0x2084d7040),
"_Ctype_long":(*main.Type)(0x2084d7280),
"_Ctype_struct_objc_ivar":(*main.Type)(0x2084d7700),
"_Ctype_Method":(*main.Type)(0x2083eac00),
"_Ctype_struct_objc_selector":(*main.Type)(0x2084d7a80),
"_Ctype_IMP":(*main.Type)(0x2084d7cc0),
"_Ctype_struct_objc_method":(*main.Type)(0x2084d7d80),
"_Ctype_uint":(*main.Type)(0x2084d7f80),
"_Ctype_Protocol":(*main.Type)(0x2083eb000),
"_Ctype_char":(*main.Type)(0x2084d71c0),
"_Ctype_struct_objc_ivar_list":(*main.Type)(0x2084d7780)}
t:&main.Type{Size:8, Align:-1, C:(*main.TypeRepr)(0x2084f66f0),
Go:(*ast.Ident)(0x2084e53c0), EnumValues:map[string]int64(nil), Typedef:""}
t.C:&main.TypeRepr{Repr:"Protocol", FormatArgs:[]interface {}(nil)}
### expr:(*main.Type)(nil)

so while all the parts of the typedef[...] line are valid, the typedef[...] expression
itself is not. I'm not sure what's going on here.

I'm running Mac OS X 10.8 with go version
    go version devel +f39dff1bf0d4 Thu Jun 19 22:18:24 2014 +1000 darwin/amd64
and clang version
    Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
    Target: x86_64-apple-darwin12.5.0
    Thread model: posix
but people at andlabs/ui#9 have different setups.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions