View previous topic :: View next topic |
Author |
Message |
Thorn
Joined: 12 Sep 2005 Posts: 10
|
Posted: Mon Sep 19, 2005 4:34 am Post subject: Create Windows program - how? |
|
|
Hi, D-people!
Is there any good example how to create D program for Windows using Ares library? How to compile/link them? |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Mon Sep 19, 2005 9:33 am Post subject: |
|
|
This is a good start:
http://www.digitalmars.com/d/windows.html
Replace "std.c.windows" with "sys.c.windows" and the example almost compiles. DMD still complains about an undefined symbol, __Dmain, but I think this may be a compiler issue. However, I added this to the sample:
int main() {}
and then it compiled and ran fine. Now that I've tried it, I don't really like how this process works, so I'll probably add a module to Ares to simplify things. It will be in sys.windows. Note that this means sys.c.windows will change to sys.windows.c and sys.c.linux will change to sys.linux.c, which seems to make more sense anyway. |
|
Back to top |
|
|
sean
Joined: 24 Jun 2004 Posts: 609 Location: Bay Area, CA
|
Posted: Mon Oct 17, 2005 12:23 pm Post subject: |
|
|
Copied from digitalmars.D.learn:
Quote: | I was promped to try creating a Windows application in D recently and was struck
by how complicated winsamp made it seem--no user should ever have to copy
portions of proprietary runtime code (dmain2) to make her D app work. This is
an alternate method I cooked up that works equally well and show be a bit more
portable:
Code: | import sys.windows.c.windows;
/*
* Pass on all the real work to the standard main function.
*/
extern (C) int main( int argc, char **argv );
extern (Windows) int WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow )
{
return main( 1, &lpCmdLine );
}
/*
* Define your D main function as usual. This will be called through
* the extern(C) main function called above. That's it!
*/
void main()
{
} |
A working sample using this method (based on samples.d.winsamp bundled with DMD)
is available here:
http://home.f4.ca/sean/d/winsamp.zip
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|