On Wed, Sep 9, 2020 at 8:17 PM Ian Lance Taylor <i...@golang.org> wrote:
> Exact alignment/offset compatibility with the C ABI is not a goal. > Sorry. (It's actually harder than one might think to maintain that > kind of compatibility. For example, on x86, the C ABI uses one > alignment for double variables and a different alignment for double > variables that appear as a field in a struct. Unless, of course, you > use the -malign-double option. And more generally some platforms have > multiple C ABIs, including x86 if you count the MCU psABI.) > > The Go structs in the syscall package that need to match C structs are > carefully written to work correctly. > > You may find the cgo -godefs option to be helpful, as it provides Go > structs that exactly match C structs, given a particular set of > compiler options. Thanks a lot for the clarification. Assuming that IIRC, cgo -godefs acquire the alignment/offset info by invoking the C compiler, it's unfortunately not a good option for a project that aims to avoid CGo in the first place. But I now think there's a feasible solution to this problem, having not as high a cost as I feared first when reading your answer. I shall see tomorrow. Thanks again. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/CAA40n-Vq1d2mFwmb4FVjuAdmCfa%3Du%2BoNBqEoGmY%2B_ba2j5WBWw%40mail.gmail.com.