Why is this code returning the wrong type?

David d at dav1d.de
Thu May 23 09:30:14 PDT 2013


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 changes in a file.
>  */
> class Example
> {
>     /**
>      * Member variables.
>      */
>     private FILE* _file;
> 
>     /**
>      * Constructor.
>      */
>     public this(string file)
>     {
>         this._file = new File(file, "r");
>     }
> }

Because that's not the same: File != FILE
you probably want the .handle


More information about the Digitalmars-d-learn mailing list