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: nob...@puremagic.com
          Reporter: n...@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.

--

Reply via email to