Thread overview
user-defined attributes
Feb 08, 2002
Pavel Minayev
Feb 08, 2002
Walter
Feb 08, 2002
Pavel Minayev
Feb 08, 2002
Walter
February 08, 2002
Walter, is it possible to add user-defined attributes to the language - something that would conform to this in C:

    #ifdef DLL
        #define MYEXPORT __stdcall _export
    #else
        #define MYEXPORT __cdecl
    #endif
    ...
    MYEXPORT void foo() { }

It could look like this:

    version (DLL)
        attribute MyExport = extern(Windows) export;
    else
        attribute MyExport = extern(D);
    ...
    attribute(MyExport) void foo() { }

Could be helpful in writing projects that can be either
static libs or DLLs, as well as porting such (zlib!) to
D.


February 08, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:a41776$25eb$1@digitaldaemon.com...
> Walter, is it possible to add user-defined attributes to the language - something that would conform to this in C:
>
>     #ifdef DLL
>         #define MYEXPORT __stdcall _export
>     #else
>         #define MYEXPORT __cdecl
>     #endif
>     ...
>     MYEXPORT void foo() { }
>
> It could look like this:
>
>     version (DLL)
>         attribute MyExport = extern(Windows) export;
>     else
>         attribute MyExport = extern(D);
>     ...
>     attribute(MyExport) void foo() { }
>
> Could be helpful in writing projects that can be either
> static libs or DLLs, as well as porting such (zlib!) to
> D.

Why would functions in a DLL need a different calling convention?


February 08, 2002
"Walter" <walter@digitalmars.com> wrote in message news:a41imd$2pnk$2@digitaldaemon.com...

> Why would functions in a DLL need a different calling convention?

Because it might be called from languages other than D.


February 08, 2002
"Pavel Minayev" <evilone@omen.ru> wrote in message news:a41jgh$2q47$1@digitaldaemon.com...
> "Walter" <walter@digitalmars.com> wrote in message news:a41imd$2pnk$2@digitaldaemon.com...
>
> > Why would functions in a DLL need a different calling convention?
>
> Because it might be called from languages other than D.

You can always just leave it in the C or Windows calling convention.