Why won't the following code compile? Here's the error:
filewatcher.d(21): Error: cannot implicitly convert expression
(new File(file, r)) of type File* to shared(_iobuf)*
/**
* Imports.
*/
import std.stdio;
/**
* A class to watch for changes in a file.
*/
class Example
{
/**
Am 23.05.2013 18:27, schrieb Gary Willoughby:
Why won't the following code compile? Here's the error:
filewatcher.d(21): Error: cannot implicitly convert expression (new
File(file, r)) of type File* to shared(_iobuf)*
/**
* Imports.
*/
import std.stdio;
/**
* A class to watch for
On Thursday, 23 May 2013 at 16:27:19 UTC, Gary Willoughby wrote:
Why won't the following code compile? Here's the error:
filewatcher.d(21): Error: cannot implicitly convert expression
(new File(file, r)) of type File* to shared(_iobuf)*
/**
* Imports.
*/
import std.stdio;
/**
* A class
File is a wrapper around a FILE*, it's not the same as a FILE*
No need for new, File is a struct, new is (normally) for
classes. No need for this., although there's no harm in it.
Ah yes, thanks.
Hmmm... Following your example i'm still having problems
compiling this simple snippet:
import std.stdio;
class Example
{
private FILE _file;
public this(string file)
{
this._file = File(file, r);
}
}
Error:
test.d(9): Error: cannot implicitly
Am 23.05.2013 21:45, schrieb Gary Willoughby:
Hmmm... Following your example i'm still having problems
compiling this simple snippet:
import std.stdio;
class Example
{
private FILE _file;
public this(string file)
{
this._file = File(file, r);
}
you former
private FILE* _file wasn't an File
and your current
private FILE _file is still not File
because FILE and File is something differnt (case sensitive)
why not write
private File _file
Gah! of course. Thanks. I think i better get some sleep...