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

go/build: using #cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include" throws malformed cgo #23911

Closed
datNurd opened this issue Feb 18, 2018 · 3 comments
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Milestone

Comments

@datNurd
Copy link

datNurd commented Feb 18, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

go version go1.10 windows/386

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Windows 10 64bit

What did you do?

#cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include"
#cgo LDFLAGS: -L"C:/Program Files (x86)/somelib/lib" -lsomelib

Loading headers and library files from 'Program Files (x86)' throws malformed cgo

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

A built program

What did you see instead?

malformed #cgo argument: -IC:/Program Files (x86)/somelib/include

Loading headers and library from a library installed in Program Files (x86) throws an error. I've tried enclosing the path in quotes ("") but did not work

@namusyaka namusyaka changed the title using #cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include" throws malformed cgo cmd/cgo: using #cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include" throws malformed cgo Feb 19, 2018
@ianlancetaylor ianlancetaylor changed the title cmd/cgo: using #cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include" throws malformed cgo go/build: using #cgo CFLAGS: -I"C:/Program Files (x86)/somelib/include" throws malformed cgo Feb 20, 2018
@ianlancetaylor
Copy link
Contributor

We currently restrict the strings used in #cgo CFLAGS lines to a set of known safe characters. Parentheses are not in that set. See https://golang.org/src/go/build/build.go?#L1367.

@ianlancetaylor ianlancetaylor added NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. and removed OS-Windows labels Feb 20, 2018
@ianlancetaylor ianlancetaylor added this to the Go1.11 milestone Feb 20, 2018
@matiasinsaurralde
Copy link

I'm currently working on a cross platform CGO app and this will be really useful for my builds!

@ianlancetaylor
Copy link
Contributor

I can't convince myself that parentheses are safe in general. I'm going to close this. Sorry.

@golang golang locked and limited conversation to collaborators Jun 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made.
Projects
None yet
Development

No branches or pull requests

5 participants