Skip to content

cgo: cannot handle multiple cgo inputs per package #342

@gopherbot

Description

@gopherbot

by ibw@isaacwagner.me:

What steps will reproduce the problem?
1. Create a file: cgo1.go. Put the following text in it:

package main

import "C"

var i C.int = 0;

2. Create a file: cgo2.go. Put the following text in it:

package main

import "C"

var j C.int = 0;

3. Create a file Makefile. Put the following text in it:

include $(GOROOT)/src/Make.$(GOARCH)

TARG=cgotest
CGOFILES=\
    cgo1.go \
    cgo2.go

include $(GOROOT)/src/Make.pkg

What is the expected output? What do you see instead?

Would expect cgo to build this properly. It does not. The error is: 

cgo2.cgo2.go:8: _C_int redeclared in this block
        previous declaration at cgo1.cgo2.go:8
cgo2.cgo2.go:9: _C_void redeclared in this block
        previous declaration at cgo1.cgo2.go:9
make: *** [_go_.8] Error 1

What is your $GOOS?  $GOARCH?

linux
386


Which revision are you using?  (hg identify)

cf1a9b1f9bee+ tip

Please provide any additional information below.

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