aboutsummaryrefslogtreecommitdiff
path: root/tests/legacy/examples/cgo/import_example.go
blob: a25a69714a38eb38ea295c2275f4ca6c04d89538 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package cgo

import (
	//#cgo LDFLAGS: -lm -lversion -lc_version -L${SRCDIR}/cc_dependency
	//#cgo CPPFLAGS: -I${SRCDIR}/../..
	//#include <math.h>
	//#include "use_exported.h"
	//#include "cc_dependency/version.h"
	"C"

	"github.com/bazelbuild/rules_go/examples/cgo/sub"
)

// Nsqrt returns the square root of n.
func Nsqrt(n int) int {
	return int(sub.Floor(float64(C.sqrt(C.double(n)))))
}

func PrintGoVersion() {
	C.PrintGoVersion()
}

func printCXXVersion() {
	C.PrintCXXVersion()
}

func ReturnDefined() int {
	return int(C.DEFINED_IN_COPTS)
}