September 19, 2003 static constructors for modules / files ? | ||||
---|---|---|---|---|
| ||||
Sorry I havent gotten to use D that much , stretched on time like everyone here. I see this in stream.d --------------------- File stdin, stdout, stderr; version (Win32) { // API imports private extern(Windows) { private import windows; HANDLE GetStdHandle(DWORD); } static this() { // open standard I/O devices stdin = new File(GetStdHandle(-10), FileMode.In); stdout = new File(GetStdHandle(-11), FileMode.Out); stderr = new File(GetStdHandle(-12), FileMode.Out); } } and its outside of any class, is this a module initalizer ? Would I have to put this in a version statement or how could I use this in my own project ( i mean the seemingly anonymous static this() ) ? Thanks, Charles |
September 19, 2003 Re: static constructors for modules / files ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Charles Sanders | Spoke to soon sorry, at the bottom here: http://www.digitalmars.com/d/module.html Doh! "Charles Sanders" <sanders-consulting@comcast.net> wrote in message news:bke355$2877$1@digitaldaemon.com... > Sorry I havent gotten to use D that much , stretched on time like everyone here. > > I see this in stream.d > --------------------- > > File stdin, stdout, stderr; > > version (Win32) > { > // API imports > private extern(Windows) > { > private import windows; > HANDLE GetStdHandle(DWORD); > } > > static this() > { > // open standard I/O devices > stdin = new File(GetStdHandle(-10), FileMode.In); > stdout = new File(GetStdHandle(-11), FileMode.Out); > stderr = new File(GetStdHandle(-12), FileMode.Out); > } > } > > and its outside of any class, is this a module initalizer ? Would I have to > put this in a version statement or how could I use this in my own project > ( i mean the seemingly anonymous static this() ) ? > > Thanks, > Charles > > |
Copyright © 1999-2021 by the D Language Foundation