Skip to content

Commit

Permalink
README example: line wrap added
Browse files Browse the repository at this point in the history
  • Loading branch information
JupiterRider committed Dec 27, 2024
1 parent f6539f0 commit fb79900
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ func main() {
// create a new ffi.Type which defines the fields of the Item struct
typeItem := ffi.NewType(&ffi.TypePointer, &ffi.TypeDouble, &ffi.TypeUint32)

// get the IsItemValid function and describe its signature (for bool we use ffi.TypeUint8)
// get the IsItemValid function and describe its signature
// (for bool we use ffi.TypeUint8)
isItemValid, err := lib.Prep("IsItemValid", &ffi.TypeUint8, &typeItem)
if err != nil {
panic(err)
Expand All @@ -142,10 +143,12 @@ func main() {
item.Price = 0.22
item.Category = Groceries

// the return value is stored in a 64-bit integer type, because libffi cannot handle smaller integer types as return value
// the return value is stored in a 64-bit integer type, because libffi
// cannot handle smaller integer types as return value
var result ffi.Arg

// call the C function (keep in mind that you have to pass pointers and not the values themselves)
// call the C function
// (keep in mind that you have to pass pointers and not the values themselves)
isItemValid.Call(&result, &item)

if byte(result) != 0 {
Expand Down

0 comments on commit fb79900

Please sign in to comment.