www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Conflicting variable- stdin

reply DemmeGod <me demmegod.com> writes:
I get the following error:
dmd -I. -Ibuild -c -ofbuild/daemon.o build/daemon.d
/usr/share/dmd/src/phobos/std/stream.d(2050): variable stdin conflicts with
stdio.stdin at /usr/share/dmd/src/phobos/std/c/stdio.d(131)

When trying to compile the following code:
<snip>
private import com.neuralnexus.nnstore;
private import std.stream;
private import std.asserterror;

void main()
{
	while (1)
	{
		char[] inp = stdin.readLine();
		try
		{
			outTest(inp);
		}
		catch (AssertError e)
		{
			printf(e.toString() ~ "\n");
		}
	}
}
</snip>

This feels like a stupid error, but I can't find an obvious solution. 
When the stdin.readLine() is commented out, it compiles no problem.

Any suggestions?

TIA
John
Jun 08 2004
next sibling parent reply "Ivan Senji" <ivan.senji public.srce.hr> writes:
I had lots of those errors:
try something like
alias std.stream.stdin stdin;
after the imports.

"DemmeGod" <me demmegod.com> wrote in message
news:pan.2004.06.08.21.01.06.108753 demmegod.com...
 I get the following error:
 dmd -I. -Ibuild -c -ofbuild/daemon.o build/daemon.d
 /usr/share/dmd/src/phobos/std/stream.d(2050): variable stdin conflicts

 When trying to compile the following code:
 <snip>
 private import com.neuralnexus.nnstore;
 private import std.stream;
 private import std.asserterror;

 void main()
 {
 while (1)
 {
 char[] inp = stdin.readLine();
 try
 {
 outTest(inp);
 }
 catch (AssertError e)
 {
 printf(e.toString() ~ "\n");
 }
 }
 }
 </snip>

 This feels like a stupid error, but I can't find an obvious solution.
 When the stdin.readLine() is commented out, it compiles no problem.

 Any suggestions?

 TIA
 John

Jun 08 2004
parent DemmeGod <me demmegod.com> writes:
Thanks. That works.  I tried doing:
char[] inp = std.stream.stdin.readLine();
but it spits out an undefined error.  What's different about alias that it
works?

John

On Tue, 08 Jun 2004 23:02:43 +0200, Ivan Senji wrote:

 I had lots of those errors:
 try something like
 alias std.stream.stdin stdin;
 after the imports.
 

Jun 08 2004
prev sibling parent DemmeGod <me demmegod.com> writes:
Forgot to mention: if I make the two imports in AssertError private, it
works, but I'm not sure how this will effect everything/anything else.

On Tue, 08 Jun 2004 17:01:09 -0400, DemmeGod wrote:

 I get the following error:
 dmd -I. -Ibuild -c -ofbuild/daemon.o build/daemon.d
 /usr/share/dmd/src/phobos/std/stream.d(2050): variable stdin conflicts
 with stdio.stdin at /usr/share/dmd/src/phobos/std/c/stdio.d(131)
 
 When trying to compile the following code: <snip>
 private import com.neuralnexus.nnstore; private import std.stream;
 private import std.asserterror;
 
 void main()
 {
 	while (1)
 	{
 		char[] inp = stdin.readLine();
 		try
 		{
 			outTest(inp);
 		}
 		catch (AssertError e)
 		{
 			printf(e.toString() ~ "\n");
 		}
 		}
 	}
 </snip>
 
 This feels like a stupid error, but I can't find an obvious solution. When
 the stdin.readLine() is commented out, it compiles no problem.
 
 Any suggestions?
 
 TIA
 John

Jun 08 2004