A couple of months ago, I wrote bindings to a C library
<http://github.com/fuzxxl/nfc> that uses structs with non-standard
alignment (i.e. packed structs). The structs look like this:

struct example {
     uint8_t bar;
     size_t baz;

I want to marshall these structs into equal Go structs like this:

type Example struct {
     bar uint8
     baz uint

Now, since some fields have alignments that cannot be represented in Go
(compare issue #7560 <https://code.google.com/p/go/issues/detail?id=7560>),
I have a hard time writing the marshalling code. Originally, I planned to
write C functions that receive pointers to a C struct and the corresponding
Go struct which do the marshalling and are called from Go with pointers
allocated on the Go heap, but I haven't figured out yet how to write C
functions whose arguments have types defined in Go code. I filed issue #8114
<https://code.google.com/p/go/issues/detail?id=8114> about this which
hasn't received any attention yet.

I'd like to know how this kind of situation is handled by other wrappers. I
wrote two Stackoverflow questions (1
<http://stackoverflow.com/q/23919677/417501>, 2
<http://stackoverflow.com/q/25564490/417501>) about the problems I'm having
but I didn't receive any helpful answers. What can I do to solve the
problems I'm having?

Your sincerely,
Robert Clausecker

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

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 1 | next ›
Discussion Overview
groupgolang-nuts @
postedAug 29, '14 at 12:05p
activeAug 29, '14 at 12:05p

1 user in discussion

Robert Clausecker: 1 post



site design / logo © 2022 Grokbase