26.C_sizeof_struct

command
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 7, 2025 License: MIT Imports: 2 Imported by: 0

README

これは何?

cgoにてGo側でCの構造体のサイズを取得するサンプルです。

malloc() には、確保するサイズを指定する必要がありますが、通常C言語側では

sizeof(struct A)

としますが、cgo側では以下のように構造体のサイズを取得することが出来ます。

var sz = C.sizeof_struct_(構造体)

typedefしていない構造体を扱う場合の宣言方法は 25.C_struct_not_typedef を参照ください。

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL