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

The new cgo can't handle #define'd function aliases in C headers #520

Closed
rsaarelm opened this issue Jan 12, 2010 · 3 comments
Closed

The new cgo can't handle #define'd function aliases in C headers #520

rsaarelm opened this issue Jan 12, 2010 · 3 comments

Comments

@rsaarelm
Copy link
Contributor

Before filing a bug, please check whether it has been fixed since
the latest release: run "hg pull -u" and retry what you did to
reproduce the problem.  Thanks.

What steps will reproduce the problem?

With libsdl headers available, try to compile the following source code
using a regular cgo Makefile:

package main

/*
#include <SDL.h>
*/
import "C"

func BlitTest(a, b *C.SDL_Surface) {
    C.SDL_BlitSurface(a, nil, b, nil)
}


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

Instead of compiling, I get:

$ make
CGOPKGPATH= /home/rsaarelm/bin/cgo -I/usr/include/SDL -D_GNU_SOURCE=1
-D_REENTRANT sdl.go 
/home/rsaarelm/bin/8g -o _go_.8 sdl.cgo1.go _cgo_gotypes.go
_cgo_gotypes.go:81: undefined: SDL_UpperBlit
make: *** [_go_.8] Error 1

What is your $GOOS?  $GOARCH?

linux 386

Which revision are you using?  (hg identify)

f467eb7716c4 tip

Please provide any additional information below.

From include/SDL/SDL_video.h:

#define SDL_BlitSurface SDL_UpperBlit
@rsaarelm
Copy link
Contributor Author

Comment 1:

Just to clarify, this is something that used to work with the previous cgo.
There's a similar problem with constants that are #defined to be aliased to other
#define constants, as in
#define foo 1
#define bar foo

@dhobsd
Copy link
Contributor

dhobsd commented Jan 13, 2010

Comment 2:

I'm sure this is due to the changes I made to support `referencing' #defined
constants, though I'm not entirely sure why it happens yet. If I can't come up with a
solution, a reasonable compromise would be to only allow this for things we can
determine to be numeric or string constants.

@rsc
Copy link
Contributor

rsc commented Jan 14, 2010

Comment 3:

This issue was closed by revision e8afb6d.

Status changed to Fixed.

Merged into issue #-.

@rsaarelm rsaarelm added the fixed label Jan 14, 2010
@golang golang locked and limited conversation to collaborators Jun 24, 2016
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

4 participants