[Issue 19004] New: Allow passing a string literal to an extern(C) variadic parameter
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jun 18 12:54:08 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=19004
Issue ID: 19004
Summary: Allow passing a string literal to an extern(C)
variadic parameter
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nick at geany.org
A string literal usually implicitly converts to a const(char)*. This is not
considered when passing one to an extern(C) variadic parameter - due to the
literal being interpreted as a slice, which is disallowed. The string should be
implicitly cast to a pointer, as string literals are always \0-terminated. This
is handy for C string compatibility, e.g. for formatting arguments:
dmd/toobj.d:
f.error("must be `extern(C)` for `pragma(%s)`",
isCtor ? "crt_constructor".ptr : "crt_destructor".ptr);
The `.ptr` property should not be necessary.
--
More information about the Digitalmars-d-bugs
mailing list