Skip to content

cgo enum value handling varies depending on whether enum type is referenced #479

@gopherbot

Description

@gopherbot

by emage@spamcop.net:

What steps will reproduce the problem?
1. Create the following file:

package enum

// typedef enum {a, b, c, d} foo;
import "C"

import "fmt"

func Test() {fmt.Printf("%d %d %d %d\n", C.a, C.b, C.c, C.d); }

2. Run cgo on it and note that it generates references of the form _C_a
referring to an enum.so file
3. Append the following line and rerun cgo:

func Test2() C.foo { return C.a; }

The addition of this line causes constants a, b, c, and d to be defined in
the package, and causes the generated Test() code to refer to those constants.

The latter behavior seems more correct and should probably happen in either
case.

Which revision are you using?  (hg identify)

a6fcf4303b0a release/release.2009-12-22

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions