FAQ
I'm running into an issue using go 1.5.1, cgo, on Linux/amd64.

I'm building a Go library to interface with an in-house C library
(proprietary). cgo is generating all the correct struct definitions except
for one. I'm running out of ideas how to make this work. Any ideas?

_Ctype_struct___3 and _Ctype_struct_q2_table_schema should not be struct
{}, they should contain 3 members from the header file:

typedef struct {
     const char *tablename;
     const char *description;
     q2_column_description *columns;
} q2_table_schema;


yet they are empty (from go tool cgo src/q2.go):

type _Ctype_struct___0 struct {
//line :1
         d [16]byte
//line :1
         null _Ctype_uint
//line :1
}


type _Ctype_struct___2 struct {
//line :1
         name *_Ctype_char
//line :1
         description *_Ctype_char
//line :1
         _type _Ctype_q2_data_type
//line :1
         aggtype _Ctype_q2_aggregation_type
//line :1
         nullable _Ctype_q2_nullable
//line :1
         mergetype _Ctype_q2_merge_type
//line :1
}


type _Ctype_struct___3 struct{}


type _Ctype_struct__q2_conn struct{}


type _Ctype_struct_in_addr struct {
//line :1
         s_addr _Ctype_in_addr_t
//line :1
}


type _Ctype_struct_q2_table_schema struct{}



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Ian Lance Taylor at Dec 3, 2015 at 8:49 pm

    On Thu, Dec 3, 2015 at 10:02 AM, Adam Flott wrote:
    I'm running into an issue using go 1.5.1, cgo, on Linux/amd64.

    I'm building a Go library to interface with an in-house C library
    (proprietary). cgo is generating all the correct struct definitions except
    for one. I'm running out of ideas how to make this work. Any ideas?
    I have not seen this before. Really hard to suggest anything without
    a test case. Can you try to boil it down to something you can share?

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Adam Flott at Dec 5, 2015 at 7:47 pm

    On Thursday, December 3, 2015 at 3:49:41 PM UTC-5, Ian Lance Taylor wrote:
    On Thu, Dec 3, 2015 at 10:02 AM, Adam Flott <adam.m...@gmail.com
    <javascript:>> wrote:
    I'm running into an issue using go 1.5.1, cgo, on Linux/amd64.

    I'm building a Go library to interface with an in-house C library
    (proprietary). cgo is generating all the correct struct definitions except
    for one. I'm running out of ideas how to make this work. Any ideas?
    I have not seen this before. Really hard to suggest anything without
    a test case. Can you try to boil it down to something you can share?

    I figured it out. There is a regression in Go 1.3+ (possible related to
    https://golang.org/doc/go1.3#cgo) with anonymous structs and cgo. When I
    changed our structs to use the same name (e.g. typedef struct T { ... } T)
    cgo worked as expected. Would a small test case be still be helpful?

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Ian Lance Taylor at Dec 5, 2015 at 8:32 pm

    On Sat, Dec 5, 2015 at 11:47 AM, Adam Flott wrote:
    On Thursday, December 3, 2015 at 3:49:41 PM UTC-5, Ian Lance Taylor wrote:
    On Thu, Dec 3, 2015 at 10:02 AM, Adam Flott wrote:
    I'm running into an issue using go 1.5.1, cgo, on Linux/amd64.

    I'm building a Go library to interface with an in-house C library
    (proprietary). cgo is generating all the correct struct definitions
    except
    for one. I'm running out of ideas how to make this work. Any ideas?
    I have not seen this before. Really hard to suggest anything without
    a test case. Can you try to boil it down to something you can share?

    I figured it out. There is a regression in Go 1.3+ (possible related to
    https://golang.org/doc/go1.3#cgo) with anonymous structs and cgo. When I
    changed our structs to use the same name (e.g. typedef struct T { ... } T)
    cgo worked as expected. Would a small test case be still be helpful?
    Sounds like that one is covered. Thanks.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 3, '15 at 8:35p
activeDec 5, '15 at 8:32p
posts4
users2
websitegolang.org

2 users in discussion

Adam Flott: 2 posts Ian Lance Taylor: 2 posts

People

Translate

site design / logo © 2022 Grokbase