mirror of
https://github.com/golang/go
synced 2024-11-19 10:04:56 -07:00
2fdff9586b
This is, in effect, what the gc toolchain does. It fixes cases where Go code refers to a C global variable; without this, if the global variable was the only thing visible in the C code, the generated cgo file might not get pulled in from the archive, leaving the Go variable uninitialized. This was reported against gccgo as https://gcc.gnu.org/PR68255 . Change-Id: I3e769dd174f64050ebbff268fbbf5e6fab1e2a1b Reviewed-on: https://go-review.googlesource.com/16775 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
18 lines
379 B
Go
18 lines
379 B
Go
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Test that it's OK to have C code that does nothing other than
|
|
// initialize a global variable. This used to fail with gccgo.
|
|
|
|
package gcc68255
|
|
|
|
/*
|
|
#include "c.h"
|
|
*/
|
|
import "C"
|
|
|
|
func F() bool {
|
|
return C.v != nil
|
|
}
|