Conflict between std.file write() and std.stdio write()

Jonathan M Davis jmdavisProg at gmx.com
Wed Oct 2 17:04:16 PDT 2013


On Thursday, October 03, 2013 01:39:38 Craig Dillabaugh wrote:
> Hello,
> I have the following program:
> 
> import std.file;
> import std.stdio;
> 
> void main( string[] args ) {
> string str = "Hello";
> write( "file.txt", str );
> 
> string hello_file = readText("file.txt");
> 
> writeln( hello_file );
> }
> 
> When I try to compile this I get:
> 
> test.d(6): Error: std.stdio.write!(string, string).write at
> /usr/include/dmd/phobos/std/stdio.d(1656) conflicts with
> std.file.write at /usr/include/dmd/phobos/std/file.d(318)
> 
> I think this should work. The example at the end of (D file I/0):
> 
> http://www.docwiki.net/view.php?pageid=145
> 
> Uses write() exactly the way I am using it here.

You have to give the full path - std.file.write. As both functions can take the 
same arguments, and you've imported both, the compiler has no way of knowing 
which you mean. So, you have to disambiguate for it. It's only a problem 
because you imported both modules.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list