Thread overview | ||||||
---|---|---|---|---|---|---|
|
November 03, 2007 void buffer | ||||
---|---|---|---|---|
| ||||
Hello, the prorgramm under linux dmd 2.007 import std.file; import std.stdio; int main() { string str1 = "Zeile 1\n", str2 = "Zeile 2 \n"; const(void)[] buf; buf ~= str1; buf ~= str2; write("test_neu.txt",buf); return 0; } gives an error: ~/dd/dmd/src/phobos/std/format.d(1983): variable std.format.formatGeneric (FileWriter!(char),const( void)[]).formatGeneric.e voids have no value Have someone an idea to fix this. manni |
November 03, 2007 Re: void buffer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Hansen | Manfred Hansen wrote:
> Hello,
>
> the prorgramm under linux dmd 2.007 import std.file;
> import std.stdio;
>
> int main() {
> string str1 = "Zeile 1\n", str2 = "Zeile 2 \n";
> const(void)[] buf;
>
> buf ~= str1; buf ~= str2;
> write("test_neu.txt",buf);
>
> return 0;
> }
>
> gives an error:
>
> ~/dd/dmd/src/phobos/std/format.d(1983): variable std.format.formatGeneric
> (FileWriter!(char),const( void)[]).formatGeneric.e voids have no
> value
>
> Have someone an idea to fix this.
>
> manni
You can't directly write out a void array, the standard library doesn't know how to do that since a void array basically means "I don't know what the type(s) of this data is/are". You'll have to cast it to string before you can write it.
Thanks,
Nathan Reed
|
November 03, 2007 Re: void buffer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nathan Reed | Nathan Reed wrote:
> Manfred Hansen wrote:
>> Hello,
>>
>> the prorgramm under linux dmd 2.007
>>
>> import std.file;
>> import std.stdio;
>>
>> int main() {
>> string str1 = "Zeile 1\n", str2 = "Zeile 2 \n";
>> const(void)[] buf;
>>
>> buf ~= str1; buf ~= str2;
>> write("test_neu.txt",buf);
>>
>> return 0;
>> }
>>
>> gives an error:
>>
>> ~/dd/dmd/src/phobos/std/format.d(1983): variable std.format.formatGeneric
>> (FileWriter!(char),const( void)[]).formatGeneric.e voids have
>> no value
>>
>> Have someone an idea to fix this.
>>
>> manni
>
> You can't directly write out a void array, the standard library doesn't know how to do that since a void array basically means "I don't know what the type(s) of this data is/are". You'll have to cast it to string before you can write it.
>
> Thanks,
> Nathan Reed
This example run with dmd 2.002 . I believe there has someting change in const/infariant situation.
The write method in std.file (line 147) look like void write(in string name, const void[] buffer)
This is what i want.
Sincerely manni
|
November 04, 2007 Re: void buffer | ||||
---|---|---|---|---|
| ||||
Posted in reply to Manfred Hansen | Manfred Hansen escribió: > Nathan Reed wrote: > >> Manfred Hansen wrote: >>> Hello, >>> >>> the prorgramm under linux dmd 2.007 >>> import std.file; >>> import std.stdio; >>> >>> int main() { >>> string str1 = "Zeile 1\n", str2 = "Zeile 2 \n"; >>> const(void)[] buf; >>> >>> buf ~= str1; buf ~= str2; >>> write("test_neu.txt",buf); >>> >>> return 0; >>> } >>> >>> gives an error: >>> >>> ~/dd/dmd/src/phobos/std/format.d(1983): variable std.format.formatGeneric >>> (FileWriter!(char),const( void)[]).formatGeneric.e voids have >>> no value >>> >>> Have someone an idea to fix this. >>> >>> manni >> You can't directly write out a void array, the standard library doesn't >> know how to do that since a void array basically means "I don't know >> what the type(s) of this data is/are". You'll have to cast it to string >> before you can write it. >> >> Thanks, >> Nathan Reed > > This example run with dmd 2.002 . I believe there has someting change > in const/infariant situation. > > The write method in std.file (line 147) look like void write(in string name, const void[] buffer) > > This is what i want. > > Sincerely manni > > > In that case, use "std.file.write", or "alias std.file.write write" in your module. -- Carlos Santander Bernal |
Copyright © 1999-2021 by the D Language Foundation