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

cmd/go: cgo flags drops quotes. #12281

omeid opened this Issue Aug 23, 2015 · 1 comment


None yet
3 participants
Copy link

omeid commented Aug 23, 2015

There doesn't seem to be a way to pass a quoted value with cgo flags.

package libsass

#cgo CFLAGS: -D VERSION="3.2.4-0ae11a4"

char* version(void) {
  return VERSION;
import "C"

func Version() string {
    return C.GoString(C.version())
$ go build -x -v
mkdir -p $WORK/test/cgoflag/_obj/
mkdir -p $WORK/test/cgoflag/_obj/exe/
cd /home/ome/go/src/test/cgoflag
CGO_LDFLAGS="-g" "-O2" /usr/local/go/pkg/tool/linux_amd64/cgo -objdir $WORK/test/cgoflag/_obj/ -importpath test/cgoflag -- -I $WORK/test/cgoflag/_obj/ -D VERSION=3.2.4-0ae11a4 main.go
# test/cgoflag
./main.go: In function 'version':
<command-line>:0:9: error: too many decimal points in number
./main.go:8:10: note: in expansion of macro 'VERSION'
   return VERSION;
<command-line>:0:15: error: invalid suffix "ae11a4" on integer constant
./main.go:8:10: note: in expansion of macro 'VERSION'
   return VERSION;

I have also tried '"3.2.4-0ae11a4"' and some other variations, they all yield:
can't load package: package test/cgoflag: /home/ome/go/src/test/cgoflag/main.go: malformed #cgo argument: VERSION="3.2.4-0ae11a4"

@ianlancetaylor ianlancetaylor changed the title cmd/compile: cgo flags drops quotes. cmd/go: cgo flags drops quotes. Aug 25, 2015

@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Aug 25, 2015


This comment has been minimized.

Copy link

c4milo commented Sep 21, 2015

I'm running into this same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.