On Thu, 18 Nov 2010 13:53:53 -0500, Steve Teale
<[email protected]> wrote:
On Thu, 18 Nov 2010 08:33:12 -0500, Steven Schveighoffer wrote:
I think using a class in D is a good idea. But what you may need is
global functions which forward to your class methods. This is how I
would probably do it.
-Steve
Steve,
Thanks. I kind of went that way. Having done the laborious C OOP style
thing, I put most of the methods back into the struct, just leaving the
extern(Windows) functions at global scope - they referred to the
__gshare'd object explicitly - I hate that.
Then I hid all of the crap behind a class that sneakily referred to the
__gshared struct, but at least now to an external user of the module the
interface looks much the same as it did before.
Now it works OK with the test case example - a service that just writes
entries in the event log. However, the real service I'm trying to update
works fine if I run it in debug mode (i.e. basically as just an
executable), but if I run it as a service it seems to crash the first
time I use a RegExp.find().
As I said before, I don't know if the thread being created by the windows
service procedure is properly initializing the D modules of the
library/runtime. Try as the first line of ServiceMain to initialize the
current thread:
auto mythread = thread_attachThis();
see http://www.digitalmars.com/d/2.0/phobos/core_thread.html
-Steve