Thread overview
Win32 Apps, clumsy compiler .def?
Dec 15, 2003
Felix
Dec 16, 2003
Georg Wrede
Dec 16, 2003
Felix
Dec 16, 2003
Charles
December 15, 2003
The Win32 apps programming (i.e. the .def file), the WinMain and DllMain
auto-recognition seems to be a little clumsy for me. First, I dunno like the
def file and I see no meaning for it.
Maybe for some external files, compiler switchs we could use some #pragmas. By
example, a #pragma should be valid only in the module it defines (also in the
imported ones). Would be a little less clumsy, isn't?
And if I want to have a function named "winmain". Is this a reserved word in D?
But DllMain, libmain etc.?
I read smhwere that C/C++ compilers accept main or winmain, doesn't care about,
once the -WindowsApp flag is passed. Really, I see no meaning except a
particular prototype.
AFAIK, the -WinApp flag gives some default libs (kernel32.dll etc.) and the
stub... Is the stub really necessary (nowadays)?
By the way, I used once the go!asm assembler and this one succeeded to link(?)
directly against the kernel32.dll etc. (.dll files). Should be this possible
also for D (in dynamic linking?)?

Sorry if the message is clumsier than the "clumsy" word...


December 16, 2003
In article <brkpp9$d7t$1@digitaldaemon.com>, Felix says...
>Sorry if the message is clumsier than the "clumsy" word...

Happens to me, too, sometimes. You may want to review
the message, and then rewrite it so that "the less fortunate"
in this newsgroup can handle it (including me...), too.

After all, it really looked like you had some valid and very relevant questions.

georg


December 16, 2003
Thks, but I do not think there is any great stuff in my message. What I liked to know was, basically:

-why the filename.def is required when programming win32 apps? I quote the docs:

"
A .def (Module Definition File) with at least the following two lines in it:

EXETYPE NT
SUBSYSTEM WINDOWS

Without those, Win32 will open a text console window whenever the application is
run.
"
I see no reason, once the application is a win32 one, why it opens a text
console window? For the stub? (i.e. the little program which displays "This
program cannot be run in MS-DOS mode" or "This program requires Microsft
Windows") It is still useful (the stub itself) nowadays?
-more, if the lines in .def file are required, one may replace 'em by some
#pragma's directives? as: "#pragma def exetype nt" etc. It is easier to use than
another file...
-And the last: are "WinMain", "DllMain" etc. reserved keywords under D? I quote:
"
The presence of WinMain() is recognized by the compiler causing it to emit a
reference to __acrtused_dll and the phobos.lib runtime library.
"
This means that:
-if the compiler recognize the "winmain" keyword it knows it is a windows app?
so, if it is the case, why the .def file?
-can I have a "winmain" function in a linux/dos program? Why we cannot use
simply the old "main" keyword? Even in C/C++ these are equivalents (for some
compilers, at least).

I hope these new examples are clearer. Sorry if I repeat something that was already discussed.




In article <brlkoa$1nrj$1@digitaldaemon.com>, Georg Wrede says...
>
>In article <brkpp9$d7t$1@digitaldaemon.com>, Felix says...
>>Sorry if the message is clumsier than the "clumsy" word...
>
>Happens to me, too, sometimes. You may want to review
>the message, and then rewrite it so that "the less fortunate"
>in this newsgroup can handle it (including me...), too.
>
>After all, it really looked like you had some valid and very relevant questions.
>
>georg
>
>


December 16, 2003
> -if the compiler recognize the "winmain" keyword it knows it is a windows
app?
> so, if it is the case, why the .def file?

Sometimes its desireable to have it run from a dos prompt, for debugging purposes.

Also, you don't need the .def file if thats all your wanting, the linker flags

EXET:NT

and

SU:windows

will do what you want, on the command line it looks like

dmd -L/EXET:NT -L/SU:windows  myWinApp.d

But I like your idea's of having the compiler include those for you if WinMain is detected, if we had a way to override it that would be great. Good ideas keep'em coming!

C


"Felix" <Felix_member@pathlink.com> wrote in message news:brmc6s$2qtk$1@digitaldaemon.com...
> Thks, but I do not think there is any great stuff in my message. What I
liked to
> know was, basically:
>
> -why the filename.def is required when programming win32 apps? I quote the
docs:
>
> "
> A .def (Module Definition File) with at least the following two lines in
it:
>
> EXETYPE NT
> SUBSYSTEM WINDOWS
>
> Without those, Win32 will open a text console window whenever the
application is
> run.
> "
> I see no reason, once the application is a win32 one, why it opens a text
> console window? For the stub? (i.e. the little program which displays
"This
> program cannot be run in MS-DOS mode" or "This program requires Microsft
> Windows") It is still useful (the stub itself) nowadays?
> -more, if the lines in .def file are required, one may replace 'em by some
> #pragma's directives? as: "#pragma def exetype nt" etc. It is easier to
use than
> another file...
> -And the last: are "WinMain", "DllMain" etc. reserved keywords under D? I
quote:
> "
> The presence of WinMain() is recognized by the compiler causing it to emit
a
> reference to __acrtused_dll and the phobos.lib runtime library.
> "
> This means that:
> -if the compiler recognize the "winmain" keyword it knows it is a windows
app?
> so, if it is the case, why the .def file?
> -can I have a "winmain" function in a linux/dos program? Why we cannot use
> simply the old "main" keyword? Even in C/C++ these are equivalents (for
some
> compilers, at least).
>
> I hope these new examples are clearer. Sorry if I repeat something that
was
> already discussed.
>
>
>
>
> In article <brlkoa$1nrj$1@digitaldaemon.com>, Georg Wrede says...
> >
> >In article <brkpp9$d7t$1@digitaldaemon.com>, Felix says...
> >>Sorry if the message is clumsier than the "clumsy" word...
> >
> >Happens to me, too, sometimes. You may want to review
> >the message, and then rewrite it so that "the less fortunate"
> >in this newsgroup can handle it (including me...), too.
> >
> >After all, it really looked like you had some valid and very relevant questions.
> >
> >georg
> >
> >
>
>


December 16, 2003
"Charles" <sanders-consulting@comcast.net> wrote in message
news:brmcio$2rgg$1@digitaldaemon.com...
| > -if the compiler recognize the "winmain" keyword it knows it is a
windows
| app?
| > so, if it is the case, why the .def file?
|
| Sometimes its desireable to have it run from a dos prompt, for debugging
| purposes.
|
| Also, you don't need the .def file if thats all your wanting, the linker
| flags
|
| EXET:NT
|
| and
|
| SU:windows
|
| will do what you want, on the command line it looks like
|
| dmd -L/EXET:NT -L/SU:windows  myWinApp.d
|
| But I like your idea's of having the compiler include those for you if
| WinMain is detected, if we had a way to override it that would be great.
| Good ideas keep'em coming!
|
| C
|
|
| "Felix" <Felix_member@pathlink.com> wrote in message
| news:brmc6s$2qtk$1@digitaldaemon.com...
| > Thks, but I do not think there is any great stuff in my message. What I
| liked to
| > know was, basically:
| >
| > -why the filename.def is required when programming win32 apps? I quote
the
| docs:
| >
| > "
| > A .def (Module Definition File) with at least the following two lines in
| it:
| >
| > EXETYPE NT
| > SUBSYSTEM WINDOWS
| >
| > Without those, Win32 will open a text console window whenever the
| application is
| > run.
| > "
| > I see no reason, once the application is a win32 one, why it opens a
text
| > console window? For the stub? (i.e. the little program which displays
| "This
| > program cannot be run in MS-DOS mode" or "This program requires Microsft
| > Windows") It is still useful (the stub itself) nowadays?
| > -more, if the lines in .def file are required, one may replace 'em by
some
| > #pragma's directives? as: "#pragma def exetype nt" etc. It is easier to
| use than
| > another file...
| > -And the last: are "WinMain", "DllMain" etc. reserved keywords under D?
I
| quote:
| > "
| > The presence of WinMain() is recognized by the compiler causing it to
emit
| a
| > reference to __acrtused_dll and the phobos.lib runtime library.
| > "
| > This means that:
| > -if the compiler recognize the "winmain" keyword it knows it is a
windows
| app?
| > so, if it is the case, why the .def file?
| > -can I have a "winmain" function in a linux/dos program? Why we cannot
use
| > simply the old "main" keyword? Even in C/C++ these are equivalents (for
| some
| > compilers, at least).
| >
| > I hope these new examples are clearer. Sorry if I repeat something that
| was
| > already discussed.
| >
| >
| >
| >
| > In article <brlkoa$1nrj$1@digitaldaemon.com>, Georg Wrede says...
| > >
| > >In article <brkpp9$d7t$1@digitaldaemon.com>, Felix says...
| > >>Sorry if the message is clumsier than the "clumsy" word...
| > >
| > >Happens to me, too, sometimes. You may want to review
| > >the message, and then rewrite it so that "the less fortunate"
| > >in this newsgroup can handle it (including me...), too.
| > >
| > >After all, it really looked like you had some valid and very
| > >relevant questions.
| > >
| > >georg
| > >
| > >
| >
| >
|
|

There's no need for WinMain. If you pass "-L/EXET:NT/SU:windows" as Charles
said, you can write your program with main and everything goes fine.
Also, when creating a dll, you can use the "export" keyword and you won't
need to write a .def for it.

—————————————————————————
Carlos Santander
"Charles" <sanders-consulting@comcast.net> wrote in message
news:brmcio$2rgg$1@digitaldaemon.com...
| > -if the compiler recognize the "winmain" keyword it knows it is a
windows
| app?
| > so, if it is the case, why the .def file?
|
| Sometimes its desireable to have it run from a dos prompt, for debugging
| purposes.
|
| Also, you don't need the .def file if thats all your wanting, the linker
| flags
|
| EXET:NT
|
| and
|
| SU:windows
|
| will do what you want, on the command line it looks like
|
| dmd -L/EXET:NT -L/SU:windows  myWinApp.d
|
| But I like your idea's of having the compiler include those for you if
| WinMain is detected, if we had a way to override it that would be great.
| Good ideas keep'em coming!
|
| C
|
|
| "Felix" <Felix_member@pathlink.com> wrote in message
| news:brmc6s$2qtk$1@digitaldaemon.com...
| > Thks, but I do not think there is any great stuff in my message. What I
| liked to
| > know was, basically:
| >
| > -why the filename.def is required when programming win32 apps? I quote
the
| docs:
| >
| > "
| > A .def (Module Definition File) with at least the following two lines in
| it:
| >
| > EXETYPE NT
| > SUBSYSTEM WINDOWS
| >
| > Without those, Win32 will open a text console window whenever the
| application is
| > run.
| > "
| > I see no reason, once the application is a win32 one, why it opens a
text
| > console window? For the stub? (i.e. the little program which displays
| "This
| > program cannot be run in MS-DOS mode" or "This program requires Microsft
| > Windows") It is still useful (the stub itself) nowadays?
| > -more, if the lines in .def file are required, one may replace 'em by
some
| > #pragma's directives? as: "#pragma def exetype nt" etc. It is easier to
| use than
| > another file...
| > -And the last: are "WinMain", "DllMain" etc. reserved keywords under D?
I
| quote:
| > "
| > The presence of WinMain() is recognized by the compiler causing it to
emit
| a
| > reference to __acrtused_dll and the phobos.lib runtime library.
| > "
| > This means that:
| > -if the compiler recognize the "winmain" keyword it knows it is a
windows
| app?
| > so, if it is the case, why the .def file?
| > -can I have a "winmain" function in a linux/dos program? Why we cannot
use
| > simply the old "main" keyword? Even in C/C++ these are equivalents (for
| some
| > compilers, at least).
| >
| > I hope these new examples are clearer. Sorry if I repeat something that
| was
| > already discussed.
| >
| >
| >
| >
| > In article <brlkoa$1nrj$1@digitaldaemon.com>, Georg Wrede says...
| > >
| > >In article <brkpp9$d7t$1@digitaldaemon.com>, Felix says...
| > >>Sorry if the message is clumsier than the "clumsy" word...
| > >
| > >Happens to me, too, sometimes. You may want to review
| > >the message, and then rewrite it so that "the less fortunate"
| > >in this newsgroup can handle it (including me...), too.
| > >
| > >After all, it really looked like you had some valid and very
| > >relevant questions.
| > >
| > >georg
| > >
| > >
| >
| >
|
|

There's no need for WinMain. If you pass "-L/EXET:NT/SU:windows" as Charles
said, you can write your program with main and everything goes fine.
Also, when creating a dll, you can use the "export" keyword and you won't
need to write a .def for it.

————————————————————————— Carlos Santander