Bug 24376 – ImportC: .di generator outputs D keywords for members

Status
NEW
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-02-08T20:59:58Z
Last change time
2024-12-13T19:33:07Z
Keywords
ImportC
Assigned to
No Owner
Creator
dave287091
Moved to GitHub: dmd#18212 →

Comments

Comment #0 by dave287091 — 2024-02-08T20:59:58Z
This is already noted as a limitation of ImportC (the mismatch in keywords) and in D code you can work around it using __traits. However, in the .di generator you instead get a parse error: C code: struct foo { int version; const char* function; int uint; }; .di file: // ... struct foo { int version = void; const(char)* function = void; int uint = void; } // ... Trying to import the .di file will then fail. I think ideally you solve this with adding a mechanism for D identifiers to have the same name as keywords. A new kind of string? Another way to go is to have the compiler rename identifiers that are D keywords when importing C code (say by appending an underscore). Could also only do that in the .di generation, but then importing the C code and importing the .di file are different.
Comment #1 by robert.schadek — 2024-12-13T19:33:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18212 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB