cmd/cgo: use void keyword in generated headers on extern'd function declarations with no params #68411
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
Milestone
Proposal Details
I propose that the generated header files from
--buildmode=c-shared
have void in the parenthesis when the extern'd function takes no parameters.In C, function declarations with an empty list of parameters means that the parameters are unknown. The way to declare a function that takes no parameters is to put the void keyword in the parenthesis. If you omit the void keyword then callers are allowed to specify any number of parameters to the function, although compilers can issue warnings when this happens.
In my case I'm using
jextract
to generate java bindings for a header file generated by a go project. It's is kind of a new tool. When it sees the empty parameter list it treats the function as variadic which looks slightly different on the java side. This doesn't really matter much though. I'm just including this here for context.I'm unsure what backwards compatibility concerns something like this would have. In the case of jextract it changes everything about the function call on the java side. I don't know if there are other tools that would be greatly affected by this change.
The text was updated successfully, but these errors were encountered: