Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 13, 2004 winsamp.d | ||||
---|---|---|---|---|
| ||||
Can someone explain to me why Win32 programs need these 5 externs? Cant they be put into the std.c.windows.windows import file? Also, what is the difference between extern and export?, because they both seem to be used to import functions from a dll/lib. Sorry for the loads of the questions but the spec file isnt that clear. extern (C) void gc_init(); extern (C) void gc_term(); extern (C) void _minit(); extern (C) void _moduleCtor(); extern (C) void _moduleUnitTests(); extern (Windows) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { .. |
January 13, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | extern (C) sets the calling convention. export sets the special protocall used to export functions from a DLL. They are not in their own import because they are internal names and may change. "imr1984" <imr1984_member@pathlink.com> wrote in message news:bu1hbv$m74$1@digitaldaemon.com... > Can someone explain to me why Win32 programs need these 5 externs? Cant they be > put into the std.c.windows.windows import file? Also, what is the difference > between extern and export?, because they both seem to be used to import functions from a dll/lib. Sorry for the loads of the questions but the spec file > isnt that clear. > > extern (C) void gc_init(); > extern (C) void gc_term(); > extern (C) void _minit(); > extern (C) void _moduleCtor(); > extern (C) void _moduleUnitTests(); > > extern (Windows) > int WinMain(HINSTANCE hInstance, > HINSTANCE hPrevInstance, > LPSTR lpCmdLine, > int nCmdShow) > { > > .. > > |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | > extern (C) sets the calling convention. export sets the special protocall used to export functions from a DLL. They are not in their own import because they are internal names and may change. Can we still export functions marked extern(C) but not marked export via a .DEF file, or other means? > "imr1984" <imr1984_member@pathlink.com> wrote in message news:bu1hbv$m74$1@digitaldaemon.com... > > Can someone explain to me why Win32 programs need these 5 externs? Cant > they be > > put into the std.c.windows.windows import file? Also, what is the > difference > > between extern and export?, because they both seem to be used to import functions from a dll/lib. Sorry for the loads of the questions but the > spec file > > isnt that clear. > > > > extern (C) void gc_init(); > > extern (C) void gc_term(); > > extern (C) void _minit(); > > extern (C) void _moduleCtor(); > > extern (C) void _moduleUnitTests(); > > > > extern (Windows) > > int WinMain(HINSTANCE hInstance, > > HINSTANCE hPrevInstance, > > LPSTR lpCmdLine, > > int nCmdShow) > > { > > > > .. > > > > > > |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Matthew | "Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:bu2i9h$2cn0$1@digitaldaemon.com... > > > extern (C) sets the calling convention. export sets the special protocall > > used to export functions from a DLL. They are not in their own import because they are internal names and may change. > > Can we still export functions marked extern(C) but not marked export via a > .DEF file, or other means? The same rules apply as for C. After all, a .DEF file is a command to the linker, not the compiler, and the linker knows nothing about languages. |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | "Walter" <walter@digitalmars.com> wrote in message news:bu2v2k$1r8$1@digitaldaemon.com... > > "Matthew" <matthew.hat@stlsoft.dot.org> wrote in message news:bu2i9h$2cn0$1@digitaldaemon.com... > > > > > extern (C) sets the calling convention. export sets the special > protocall > > > used to export functions from a DLL. They are not in their own import because they are internal names and may change. > > > > Can we still export functions marked extern(C) but not marked export via a > > .DEF file, or other means? > > The same rules apply as for C. After all, a .DEF file is a command to the linker, not the compiler, and the linker knows nothing about languages. Thought so. Just checking. :) |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | so are those 5 externs like prototypes to tell the compiler to reference the D library? If so why cant they be put into the windows.d import file? In article <bu1u4s$1brd$1@digitaldaemon.com>, Walter says... > >extern (C) sets the calling convention. export sets the special protocall used to export functions from a DLL. They are not in their own import because they are internal names and may change. > >"imr1984" <imr1984_member@pathlink.com> wrote in message news:bu1hbv$m74$1@digitaldaemon.com... >> Can someone explain to me why Win32 programs need these 5 externs? Cant >they be >> put into the std.c.windows.windows import file? Also, what is the >difference >> between extern and export?, because they both seem to be used to import functions from a dll/lib. Sorry for the loads of the questions but the >spec file >> isnt that clear. >> >> extern (C) void gc_init(); >> extern (C) void gc_term(); >> extern (C) void _minit(); >> extern (C) void _moduleCtor(); >> extern (C) void _moduleUnitTests(); >> >> extern (Windows) >> int WinMain(HINSTANCE hInstance, >> HINSTANCE hPrevInstance, >> LPSTR lpCmdLine, >> int nCmdShow) >> { >> >> .. >> >> > > |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to imr1984 | "imr1984" <imr1984_member@pathlink.com> wrote in message news:bu3lbl$15fl$1@digitaldaemon.com... > so are those 5 externs like prototypes to tell the compiler to reference the D > library? Yes. > If so why cant they be put into the windows.d import file? I want to keep windows.d an analogue of windows.h |
January 14, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Walter wrote:
>"imr1984" <imr1984_member@pathlink.com> wrote in message
>news:bu3lbl$15fl$1@digitaldaemon.com...
>
>
>>so are those 5 externs like prototypes to tell the compiler to reference
>>
>>
>the D
>
>
>>library?
>>
>>
>
>Yes.
>
>
>
>>If so why cant they be put into the windows.d import file?
>>
>>
>
>I want to keep windows.d an analogue of windows.h
>
>
>
>
Why no have a dwindows (or something), which imports all the related stuff for windows?
|
January 15, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote: > Walter wrote: > >> "imr1984" <imr1984_member@pathlink.com> wrote in message >> news:bu3lbl$15fl$1@digitaldaemon.com... >> >> >>> so are those 5 externs like prototypes to tell the compiler to reference >>> >> >> the D >> >> >>> library? >>> >> >> >> Yes. >> >> >> >>> If so why cant they be put into the windows.d import file? >>> >> >> >> I want to keep windows.d an analogue of windows.h >> >> >> >> > Why no have a dwindows (or something), which imports all the related stuff for windows? > Are you thinking of something like this? // ----------------------------------- // module std.windows.windows; extern (C) void gc_init(); extern (C) void gc_term(); extern (C) void _minit(); extern (C) void _moduleCtor(); extern (C) void _moduleUnitTests(); // ----------------------------------- // Seems like a good idea to me. I like to keep the mysterious stuff underneath the hood. I prefer one line with "import std.windows.windows;" to five cryptic lines that make it easy for me to mess up something. -- Justin http://jcc_7.tripod.com/d/ |
January 15, 2004 Re: winsamp.d | ||||
---|---|---|---|---|
| ||||
Posted in reply to J C Calvarese | J C Calvarese wrote:
> J Anderson wrote:
>
>> Walter wrote:
>>
>>> "imr1984" <imr1984_member@pathlink.com> wrote in message
>>> news:bu3lbl$15fl$1@digitaldaemon.com...
>>>
>>>
>>>> so are those 5 externs like prototypes to tell the compiler to reference
>>>>
>>>
>>>
>>> the D
>>>
>>>
>>>> library?
>>>>
>>>
>>>
>>>
>>> Yes.
>>>
>>>
>>>
>>>> If so why cant they be put into the windows.d import file?
>>>>
>>>
>>>
>>>
>>> I want to keep windows.d an analogue of windows.h
>>>
>>>
>>>
>>>
>> Why no have a dwindows (or something), which imports all the related stuff for windows?
>>
>
> Are you thinking of something like this?
>
> // ----------------------------------- //
>
> module std.windows.windows;
>
>
> extern (C) void gc_init();
> extern (C) void gc_term();
> extern (C) void _minit();
> extern (C) void _moduleCtor();
> extern (C) void _moduleUnitTests();
>
> // ----------------------------------- //
>
>
> Seems like a good idea to me. I like to keep the mysterious stuff underneath the hood. I prefer one line with "import std.windows.windows;" to five cryptic lines that make it easy for me to
> mess up something.
>
>
Exactly. Or parhaps.
module std.d.windows;
import std.c.windows;
extern (C) void gc_init();
extern (C) void gc_term();
extern (C) void _minit();
extern (C) void _moduleCtor();
extern (C) void _moduleUnitTests();
|
Copyright © 1999-2021 by the D Language Foundation