September 25, 2023 [Issue 24158] New: ImportC: enums created from string literal #defines don’t implicitly convert to const(char)* in D. | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24158 Issue ID: 24158 Summary: ImportC: enums created from string literal #defines don’t implicitly convert to const(char)* in D. Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: ImportC Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: dave287091@gmail.com Following D code works fine: enum X = "X"; import core.stdc.stdio; void main(){ puts(X); } However, if that enum X is the result of a #define in a C file, you get an error: // x.c #define X “X” // D code import x; import core.stdc.stdio; void main(){ puts(X); // Error } // Error: function `core.stdc.stdio.puts(scope const(char*) s)` is not callable using argument types `(char[2])` // cannot pass argument `"X"` of type `char[2]` to parameter `scope const(char*) s` -- |
Copyright © 1999-2021 by the D Language Foundation