dmd
dmd copied to clipboard
ImportC: .di generator can output invalid aliases
dave287091 reported this on 2024-02-08T20:23:24Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24373
Description
Example c file:
typedef unsigned int uint;
typedef unsigned short ushort;
If you then convert to a .di file, you get something like:
extern(C)
{
// ... bunch of junk
alias uint = uint;
alias ushort = ushort;
// ...
}
Which are not valid alias declarations.
Typedefs are converted to aliases in importC. so the only doable thing here is to maybe avoid using D type identifiers in your C typedefs.
but in cases where changes can't be made, maybe we can check if type ids are D keywords then we prepend _ when creating D symbols.
so then we get
alias _uint = uint;. could avoid complexity in trying to hack through semantics.