www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Interaction between std.stdio and std.stream...

reply "Peter Arnt" <peter_arnt yahoo.com> writes:
I don't know if this has been seen before, but here goes:
There appears to be an interaction between std.stdio and 
std.stream such that an error is generated when a File object is 
created.  Here is a simplified example of what I've been 
experiencing:

   1 import std.stdio;
   2 import std.stream;
   3
   4 void main()
   5 {
   6     auto f = File( "foo.bar", "w" );
   7 }

I have compiled the above on both Ubuntu Linux 64-bit and Windows 
64-bit systems and I get a similar error message from DMD.  here 
is the error:

$ dmd test.d
test.d(6): Error: std.stdio.File at 
/usr/include/dmd/phobos/std/stdio.d(258) conflicts with 
std.stream.File at /usr/include/dmd/phobos/std/stream.d(1820)

$

When I remove the import of std.stream, the compiler runs fine 
with no errors generated.  Again, this is a simplified example.  
My original project utilized features contained in both stdio and 
stream libraries.

Any help or direction on this would be greatly appreciated.

Best Regards,

Pete
Oct 12 2012
parent "Simen Kjaeraas" <simen.kjaras gmail.com> writes:
On 2012-49-12 18:10, Peter Arnt <peter_arnt yahoo.com> wrote:

 I don't know if this has been seen before, but here goes:
 There appears to be an interaction between std.stdio and std.stream such  
 that an error is generated when a File object is created.  Here is a  
 simplified example of what I've been experiencing:

    1 import std.stdio;
    2 import std.stream;
    3
    4 void main()
    5 {
    6     auto f = File( "foo.bar", "w" );
    7 }

 I have compiled the above on both Ubuntu Linux 64-bit and Windows 64-bit  
 systems and I get a similar error message from DMD.  here is the error:

 $ dmd test.d
 test.d(6): Error: std.stdio.File at  
 /usr/include/dmd/phobos/std/stdio.d(258) conflicts with std.stream.File  
 at /usr/include/dmd/phobos/std/stream.d(1820)

 $

 When I remove the import of std.stream, the compiler runs fine with no  
 errors generated.  Again, this is a simplified example.  My original  
 project utilized features contained in both stdio and stream libraries.

 Any help or direction on this would be greatly appreciated.
This is a newsgroup for automatic messages from Bugzilla. For help, please try digitalmars.D.learn instead. As for your specific problem, this is not a bug. Both std.stream and std.stdio define a symbol by that name, and all the better for a compile-time error to occur than it randomly choose one of them. One could argue this should be en enhancement. The solution to your problem is to specify which File you intend to use: import std.stdio : File; // Either here (will not import other symbols) import std.stream; alias std.stdio.File File; // Or here. void main( ) { auto f = std.stdio.File( "foo.bar", "w" ); // Or here. } -- Simen
Oct 14 2012