[Bug go/65134] gccgo ignores the attribute "constructor" in a subdirectory

ian at airs dot com gcc-bugzilla@gcc.gnu.org
Fri Feb 20 12:23:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134

--- Comment #1 from Ian Lance Taylor <ian at airs dot com> ---
It's pretty ugly, but a workaround is to drop something like this into sub.go:

var AlwaysFalse bool
func init() {
    if AlwaysFalse {
        C.init()
    }
}

The idea is to force in something that refers to the function that the compiler
and linker aren't smart enough to discard.



More information about the Gcc-bugs mailing list