why is string not implicit convertable to const(char*) ?

mta`chrono chrono at mta-international.net
Fri Jun 29 17:12:22 PDT 2012


does anyone know why string not implicit convertable to const(char*) ?

-------
import core.sys.posix.unistd;

void main()
{
        // ok
        unlink("foo.txt");

        // failed
        string file = "bar.txt";
        unlink(file);
}

test.d(10): Error: function core.sys.posix.unistd.unlink (const(char*))
is not callable using argument types (string)
test.d(10): Error: cannot implicitly convert expression (file) of type
string to const(char*)


More information about the Digitalmars-d-learn mailing list