Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgo: cannot handle multiple cgo inputs per package #342

Closed
gopherbot opened this issue Nov 25, 2009 · 6 comments
Closed

cgo: cannot handle multiple cgo inputs per package #342

gopherbot opened this issue Nov 25, 2009 · 6 comments

Comments

@gopherbot
Copy link
Contributor

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.
@rsc
Copy link
Contributor

rsc commented Nov 29, 2009

Comment 1:

It's true - you need to have just one cgo per package for now.

Owner changed to r...@golang.org.

Status changed to LongTerm.

@rsc
Copy link
Contributor

rsc commented Dec 2, 2009

Comment 2:

Labels changed: added cgo.

@gopherbot
Copy link
Contributor Author

Comment 3 by peter.hans.froehlich:

How long term is "LongTerm"? Should I refactor my package to work around this? Right
now there's way too much code in one file because cgo can't handle multiple. So I'd
need to extract all the cgo stuff into a low-level file, essentially defining another
level of API used internally. It would be a lot of work, but if this is not getting
fixed this year, it may be worth it for me.

@gopherbot
Copy link
Contributor Author

Comment 4 by rsc+personal@swtch.com:

Certainly not this year (2009).
You're welcome to fix it and send me a CL.
I've been hoping that someone else will pick
up the ball on cgo.  It's just not that important
to me--I think it's far more interesting to
write Go libraries than introduce dependencies
on big bloated pieces of C and C++.

@gopherbot
Copy link
Contributor Author

Comment 5 by peter.hans.froehlich:

Interesting perhaps. Useless maybe. And only ready in a few years for sure. I'll
refactor my code.

@rsc
Copy link
Contributor

rsc commented Dec 17, 2009

Comment 6:

This issue was closed by revision 9277b02.

Status changed to Fixed.

Merged into issue #-.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants