[Issue 24376] New: ImportC: .di generator outputs D keywords for members
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Feb 8 20:59:58 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24376
Issue ID: 24376
Summary: ImportC: .di generator outputs D keywords for members
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: ImportC
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: dave287091 at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list