FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Create Windows program - how?

 
Post new topic   Reply to topic     Forum Index -> Ares
View previous topic :: View next topic  
Author Message
Thorn



Joined: 12 Sep 2005
Posts: 10

PostPosted: Mon Sep 19, 2005 4:34 am    Post subject: Create Windows program - how? Reply with quote

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
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Mon Sep 19, 2005 9:33 am    Post subject: Reply with quote

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
View user's profile Send private message
sean



Joined: 24 Jun 2004
Posts: 609
Location: Bay Area, CA

PostPosted: Mon Oct 17, 2005 12:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Ares All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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