On Monday, 30 April 2012 at 18:54:41 UTC, Era Scarecrow wrote:
On Monday, 30 April 2012 at 18:50:24 UTC, Era Scarecrow wrote:
Add 'import test;' to your MyLib module.
Although that seems like it's connecting a library to
something it shouldn't... In which case perhaps a delegate
passed to the library to call myProg? Doesn't seem right either.
What is your library suppose to do? And why should it have to
access something outside it's library set? (Unless test.d is
part of the library)
I make this library to create a few classes for creating some
simple GUI components (window, buttons, text boxes, that's about
it) as a bit of a learning exercise, and for practical use.
"test.d" is not part of the library, it is just for testing the
library. What I could do that would definatly work is:
--------------
File "test.d":
--------------
import core.runtime;
import core.sys.windows.windows;
import MyLib;
pragma(lib, "MyLib.lib);
extern(Windows) {
WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR CmdLine,
int CmdShow) {
MyLibInit(hInst, hPrevInst, CmdLine, CmdShow);
}
----ENDFILE----
So I can then just pass everything my lib requires to it and then
there is no need for progMain. I'm asking this question as with
QT's source, it uses WinMain:
https://qt.gitorious.org/qt/qt/blobs/HEAD/src/winmain/qtmain_win.cpp
80 /*
81 WinMain() - Initializes Windows and calls user's startup
function main().
82 NOTE: WinMain() won't be called if the application was
linked as a "console"
83 application.
84 */
85
86 #ifdef Q_OS_WINCE
87 int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance,
LPWSTR /*wCmdParam*/, int cmdShow)
Yet you can still use "main()" from your program and then link to
QT's dll and use its functionality. I know that is C++ but that's
where I'm comming from with this.
I think you are right and my library isn't supposed to try access
"test.d"'s methods, classes, etc. and be self contained. So
should I rather go with the WinMain in my main program then pass
the parameters to MyLib like I showed before the QT reference?