xref: /aosp_15_r20/external/bazelbuild-rules_go/tests/legacy/examples/cgo/import_example.go (revision 9bb1b549b6a84214c53be0924760be030e66b93a)
1package cgo
2
3import (
4	//#cgo LDFLAGS: -lm -lversion -lc_version -L${SRCDIR}/cc_dependency
5	//#cgo CPPFLAGS: -I${SRCDIR}/../..
6	//#include <math.h>
7	//#include "use_exported.h"
8	//#include "cc_dependency/version.h"
9	"C"
10
11	"github.com/bazelbuild/rules_go/examples/cgo/sub"
12)
13
14// Nsqrt returns the square root of n.
15func Nsqrt(n int) int {
16	return int(sub.Floor(float64(C.sqrt(C.double(n)))))
17}
18
19func PrintGoVersion() {
20	C.PrintGoVersion()
21}
22
23func printCXXVersion() {
24	C.PrintCXXVersion()
25}
26
27func ReturnDefined() int {
28	return int(C.DEFINED_IN_COPTS)
29}
30