CGO did not generate header file at Mac OS

I run the below code at Win 10 and got both lib and lib.h generated, tried the same at Mac but only lib got generated, and the lib.h not appeared!!

// file: lib/go.mod

module hasan/lib

go 1.14

And

// file: lib/main.go
package main

import "fmt"

//export HelloWorld
func HelloWorld() {
	fmt.Printf("hello world")
}

func main() {}

And made the build as:

$ go build -buildmode=c-shared

No error show up

Th error was due to missing:

import "C"

In the lib/main.go this is the one responsible about generating the proper header file lib.h

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.