June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Edwards | On Thu, 20 Jun 2002 07:54:03 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote:
> there's another problem,
> running the program with stdin & stdout generate the following errors:
>
> no property 'printf' for type '_iobuf'
> no property 'scanf' for type '_iobuf'
>
> so I take them out and I get the following:
>
> Enter your name: Andrew Edwards
> Hello, !
>
> I've imported the following library files:
>
> c.stdio
> c.stdlib
> stream
The problem is, there is a nameclash between C stdin/stdout/stderr, declared somewhere in c.stdio I guess, and mine. When you took those out, you were actually calling global scanf(), which does not support D strings (stream.d has a rewritten version of it). So, either you provide the fully qualified name, like this:
stream.stdin.scanf(".*s", &name);
Or declare an alias:
File cin, cout, cerr;
static this()
{
cin = stream.stdin;
cout = stream.stdout;
cerr = stream.stderr;
}
You could also add the above into stream.d itself (I will probably do it myself for the next version). Or just don't import c.stdlib and c.stdio...
By the way, what should be the new name for standard streams? Since std* is
already taken by C ones, should I use cin/cout/cerr? Or something else?
I will appreciate any ideas...
|
June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Can't use sin/sout because sin is a math function. Probably fin/fout would be bad because fin can mean "end" in some languages. ;) Sean "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374277721585648@news.digitalmars.com... On Thu, 20 Jun 2002 07:54:03 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote: > there's another problem, > running the program with stdin & stdout generate the following errors: > > no property 'printf' for type '_iobuf' > no property 'scanf' for type '_iobuf' > > so I take them out and I get the following: > > Enter your name: Andrew Edwards > Hello, ! > > I've imported the following library files: > > c.stdio > c.stdlib > stream The problem is, there is a nameclash between C stdin/stdout/stderr, declared somewhere in c.stdio I guess, and mine. When you took those out, you were actually calling global scanf(), which does not support D strings (stream.d has a rewritten version of it). So, either you provide the fully qualified name, like this: stream.stdin.scanf(".*s", &name); Or declare an alias: File cin, cout, cerr; static this() { cin = stream.stdin; cout = stream.stdout; cerr = stream.stderr; } You could also add the above into stream.d itself (I will probably do it myself for the next version). Or just don't import c.stdlib and c.stdio... By the way, what should be the new name for standard streams? Since std* is already taken by C ones, should I use cin/cout/cerr? Or something else? I will appreciate any ideas... |
June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Pavel wrote: > By the way, what should be the new name for standard streams? Since std* is > already taken by C ones, should I use cin/cout/cerr? Or something else? I will appreciate any ideas... how about input/output/error? |
June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Edwards | On Thu, 20 Jun 2002 14:09:14 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote:
> Pavel wrote:
>
>> By the way, what should be the new name for standard streams? Since std*
> is
>> already taken by C ones, should I use cin/cout/cerr? Or something else? I will appreciate any ideas...
>
> how about input/output/error?
"input" sounds like a name of the action, not an object... besides, there's
already class Error, and I'd like to avoid such small differences.
|
June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374277721585648@news.digitalmars.com... On Thu, 20 Jun 2002 07:54:03 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote: > You could also add the above into stream.d itself (I will probably do it myself > for the next version). Or just don't import c.stdlib and c.stdio... progress made but still experiencing problems. I decided not to import c.stdlib and c.stdio but when I compile the program I get the following error messages: untitled.obj(untitled) Error 42: Symbol Undefined _Dstream_stdout_C4File untitled.obj(untitled) Error 42: Symbol Undefined _Dstream_stdin_C4File --- errorlevel 2 note: prior to compiling I went to your (Pavel) website and downloaded stream.d to replace the one in the src directory. Don't know if that makes a difference. |
June 20, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374279564276852@news.digitalmars.com... | "input" sounds like a name of the action, not an object... besides, there's | already class Error, and I'd like to avoid such small differences. good points... My final suggestion would be to use din/dout/derr. Otherwise id say to go with cin/cout/cerr. Besides, not to many people will have a problem using cin/cout/cerr because they are already familiar with it. |
June 21, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrew Edwards | On Thu, 20 Jun 2002 15:04:42 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote:
> progress made but still experiencing problems.
> I decided not to import c.stdlib and c.stdio but when I compile the program
> I get the following error messages:
>
> untitled.obj(untitled)
> Error 42: Symbol Undefined _Dstream_stdout_C4File
> untitled.obj(untitled)
> Error 42: Symbol Undefined _Dstream_stdin_C4File
> --- errorlevel 2
>
> note: prior to compiling I went to your (Pavel) website and downloaded stream.d to replace the one in the src directory. Don't know if that makes a difference.
The problem is simple: you still _link_ with the old version of stream.d, because it is inside phobos.lib, which is linked first. You need to patch your phobos.lib to replace old stream.obj inside it with the new one. Just copy stream.obj to D's LIB directory, then go there and type:
lib phobos.lib -+stream.obj;
Whew... =)
|
June 24, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374285988543056@news.digitalmars.com... On Thu, 20 Jun 2002 15:04:42 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote: > lib phobos.lib -+stream.obj; Thanks! Problem eliminated. ---------------------------------------- Next stage in development: ---------------------------------------- what is the D "stream" equivalent of establishing an output or input stream and binding it to a file? C++ e.g.: ifstream inData; ofstram outData; int main() { ... inData.open ("input.dat"); ... inData.close outData.open ("output.dat") ... outData.close ... return 0; } Thanks Andrew |
June 24, 2002 Re: Sorting strings! | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | I did what you said (lib phobos.lib -+ stream.obj), but when I try this: import file; import stream; import c.stdio; void main() { File input=new File(GetStdHandle(-10), FileMode.In); char [30] W; scanf("%s",(char*)W); printf("%s\n",(char*)W); char [] w; input.scanf("%.*s",w); printf("%.*s\n",w); } I get this: windows.d(14067): function GetStdHandle symbol windows.GetStdHandle conflicts wi th stream.GetStdHandle at stream.d(1125) Now what? ------------- "Pavel Minayev" <evilone@omen.ru> escribio en el mensaje news:CFN374285988543056@news.digitalmars.com... On Thu, 20 Jun 2002 15:04:42 -0400 "Andrew Edwards" <crxace13@comcast.net> wrote: The problem is simple: you still _link_ with the old version of stream.d, because it is inside phobos.lib, which is linked first. You need to patch your phobos.lib to replace old stream.obj inside it with the new one. Just copy stream.obj to D's LIB directory, then go there and type: lib phobos.lib -+stream.obj; |
Copyright © 1999-2021 by the D Language Foundation