[SR-7860] Compiler should help a bit if trying to call Variadic C Functions #50395
Labels
compiler
The Swift compiler itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
improvement
Additional Detail from JIRA
md5: 518da834cb4930a77a17007f41330284
Issue Description:
So currently when one tries to call a variadic C function, this is what the compiler says:
Based on this comment by Jordan, and this comment by me, the compiler should help the user a little bit more in these situations, since Swift does support alternatives. I'm talking of starting with something like this:
Swift supports alternatives to directly calling variadic functions, in the form of `va_lists` of parameters. Therefore we should also be pointing out the user to that utility, either by linking to the Documentation or by showing them an example. Either way:
Alternatively to the last sentence of (a), we could point them to a repo that uses this functionality, or to the official documentation (if it exists).
Finally, and this would be just gravy on top, the compiler could look up into the header of the imported variadic function and look up for matches like
send ~> sendv, fprintf ~> vfprintf
and show them to the user as a direct alternative of the function they are trying to call. Then, instead of the above snippet, it could instead print this:Where can this be done? I could do it if someone is willing to guide me a little 🙂
The text was updated successfully, but these errors were encountered: