26.C_malloc_struct

command
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: MIT Imports: 2 Imported by: 0

README

これは何?

cgoにてGo側で C.malloc() を利用して、構造体のメモリを動的確保するサンプルです。

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