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/cgo: _GoString_ is a reserved identifier #29877

Open
phst opened this Issue Jan 22, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@phst
Copy link

phst commented Jan 22, 2019

(Removing the template since this is not really a code bug or so.)

https://golang.org/cmd/cgo/#hdr-Go_references_to_C explains that there's a type _GoString_. However, that name is reserved (see https://en.cppreference.com/w/c/language/identifier#Reserved_identifiers), and using it is technically undefined behavior. I'd suggest renaming the type to just GoString in future versions, with the old name as undocumented and deprecated alias.

@phst

This comment has been minimized.

Copy link
Author

phst commented Jan 23, 2019

This is also the case for most other Cgo names in C.

@phst

This comment has been minimized.

Copy link
Author

phst commented Jan 24, 2019

If you're fine with renaming all the Cgo identifiers, I can take this.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Jan 25, 2019

Renaming all the cgo identifiers seems likely to break existing code. I'm not sure exactly what we can do here.

@phst

This comment has been minimized.

Copy link
Author

phst commented Jan 27, 2019

From skimming https://golang.org/cmd/cgo/, _GoString_ and the associated functions seem to be the only documented ones. I'd suggest we rename them, but provide aliases/forwarding functions marked as deprecated. If we don't care about breakages caused by using the undocumented names, we can just rename them.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

ianlancetaylor commented Jan 27, 2019

Do you happen to have a list of the undocumented names that are invalid according to the C standard?

Unfortunately history tells us that many people write code that refers to undocumented cgo names.

I'm OK with renaming GoString in the docs as long it continues to work in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment