Bug 23091 – importC: string literals no longer convert to D string type

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-05T10:27:19Z
Last change time
2024-12-13T19:22:36Z
Keywords
ImportC
Assigned to
No Owner
Creator
duser
See also
https://issues.dlang.org/show_bug.cgi?id=24158
Moved to GitHub: dmd#20097 →

Comments

Comment #0 by duser — 2022-05-05T10:27:19Z
// dmodule.d void d_fn(string s){} string d_var; // test.c __import dmodule; void fn() { d_fn("a"); d_var = "b"; } test.c(4): Error: function `dmodule.d_fn(string s)` is not callable using argument types `(char*)` test.c(4): cannot pass argument `"a"` of type `char*` to parameter `string s` test.c(5): Error: cannot implicitly convert expression `"b"` of type `char*` to `string` this worked before https://github.com/dlang/dmd/pull/14027
Comment #1 by bugzilla — 2022-05-12T06:35:29Z
The trouble is, the type of a string literal in C is `char*`. A D string is `(immutable char)[]`. Not sure what to do about it.
Comment #2 by bugzilla — 2022-09-25T05:16:30Z
`string` is (immutable char)[], which is not a C type, and so there's not much of anything C can do with it.
Comment #3 by robert.schadek — 2024-12-13T19:22:36Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20097 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB