introduce TDF_compare_debug, omit OBJ_TYPE_REF casts with it
[official-gcc.git] / libgo / misc / cgo / testsovar / cgoso.go
blob88d44c2c6ee29b1a3e7de66fc29dcc636609bc4b
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 package cgosotest
7 // This test verifies that Go can access C variables
8 // in shared object file via cgo.
11 // intentionally write the same LDFLAGS differently
12 // to test correct handling of LDFLAGS.
13 #cgo windows CFLAGS: -DIMPORT_DLL
14 #cgo linux LDFLAGS: -L. -lcgosotest
15 #cgo dragonfly LDFLAGS: -L. -l cgosotest
16 #cgo freebsd LDFLAGS: -L. -l cgosotest
17 #cgo openbsd LDFLAGS: -L. -l cgosotest
18 #cgo solaris LDFLAGS: -L. -lcgosotest
19 #cgo netbsd LDFLAGS: -L. libcgosotest.so
20 #cgo darwin LDFLAGS: -L. libcgosotest.dylib
21 #cgo windows LDFLAGS: -L. libcgosotest.dll
23 #include "cgoso_c.h"
25 const char* getVar() {
26 return exported_var;
29 import "C"
31 import "fmt"
33 func Test() {
34 const want = "Hello world"
35 got := C.GoString(C.getVar())
36 if got != want {
37 panic(fmt.Sprintf("testExportedVar: got %q, but want %q", got, want))
39 got = C.GoString(C.exported_var)
40 if got != want {
41 panic(fmt.Sprintf("testExportedVar: got %q, but want %q", got, want))