Thread overview | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
April 23, 2007 stdcall functions? | ||||
---|---|---|---|---|
| ||||
How can I make a stdcall function on Linux with DMD? extern(Windows) works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is not compatible with Linux' stdcall C functions. If this won't be changed in DMD's Linux version, I suppose I could settle with manually telling ld how to translate the names. Anyone know if this is possible or how? |
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller | Chris Miller wrote:
> How can I make a stdcall function on Linux with DMD? extern(Windows) works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is not compatible with Linux' stdcall C functions.
I didn't know Linux even had stdcall C functions.
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
> Chris Miller wrote:
>> How can I make a stdcall function on Linux with DMD? extern(Windows) works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is not compatible with Linux' stdcall C functions.
>
> I didn't know Linux even had stdcall C functions.
GCC has __attribute__((__stdcall__))
Specifically, I want to work with winelib, which is a Windows API implementation for Linux (and others); and like Windows, uses stdcall.
Also, there's a static assert in std.c.windows.windows preventing it from working with winelib; I had to comment that line out and it at least compiled, just wouldn't link due to the stdcall stuff.
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller | Chris Miller wrote:
> On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
>
>> Chris Miller wrote:
>>> How can I make a stdcall function on Linux with DMD? extern(Windows) works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is not compatible with Linux' stdcall C functions.
>>
>> I didn't know Linux even had stdcall C functions.
>
>
> GCC has __attribute__((__stdcall__))
>
> Specifically, I want to work with winelib, which is a Windows API implementation for Linux (and others); and like Windows, uses stdcall.
If Linux's stdcall functions are for compatibility with Windows, why aren't they compatible with Windows name mangling?
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Mon, 23 Apr 2007 06:15:36 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
> Chris Miller wrote:
>> On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
>>
>>> Chris Miller wrote:
>>>> How can I make a stdcall function on Linux with DMD? extern(Windows) works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is not compatible with Linux' stdcall C functions.
>>>
>>> I didn't know Linux even had stdcall C functions.
>> GCC has __attribute__((__stdcall__))
>> Specifically, I want to work with winelib, which is a Windows API implementation for Linux (and others); and like Windows, uses stdcall.
>
> If Linux's stdcall functions are for compatibility with Windows, why aren't they compatible with Windows name mangling?
I don't think that's its one and only purpose. Just what I want it for now. Besides, I don't think all Windows compilers mangle stdcall that way, and linux ones don't.
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller | Chris Miller wrote:
> Just what I want it for now. Besides, I don't think all Windows compilers mangle stdcall that way, and linux ones don't.
Hmm, DMD matches the way Microsoft's compiler mangles stdcall names.
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller Attachments:
| Chris Miller wrote:
> On Mon, 23 Apr 2007 06:15:36 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
>
>> Chris Miller wrote:
>>> On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright <newshound1@digitalmars.com> wrote:
>>>
>>>> Chris Miller wrote:
>>>>> How can I make a stdcall function on Linux with DMD?
>>>>> extern(Windows) works, but it gives it DMC's Windows name mangling
>>>>> (e.g. foo@4) that is not compatible with Linux' stdcall C functions.
>>>>
>>>> I didn't know Linux even had stdcall C functions.
>>> GCC has __attribute__((__stdcall__))
>>> Specifically, I want to work with winelib, which is a Windows API
>>> implementation for Linux (and others); and like Windows, uses stdcall.
>>
>> If Linux's stdcall functions are for compatibility with Windows, why aren't they compatible with Windows name mangling?
>
> I don't think that's its one and only purpose. Just what I want it for now. Besides, I don't think all Windows compilers mangle stdcall that way, and linux ones don't.
The attached program might help:
1) use extern(Windows) in your sources
2) compile
3) dmd_wine_fixer <your_object_file>
4) link
Thomas
|
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | On 4/23/07, Thomas Kühne <thomas-dloop@kuehne.cn> wrote: > Chris Miller wrote: > > On Mon, 23 Apr 2007 06:15:36 -0400, Walter Bright > > <newshound1@digitalmars.com> wrote: > > > >> Chris Miller wrote: > >>> On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright > >>> <newshound1@digitalmars.com> wrote: > >>> > >>>> Chris Miller wrote: > >>>>> How can I make a stdcall function on Linux with DMD? > >>>>> extern(Windows) works, but it gives it DMC's Windows name mangling > >>>>> (e.g. foo@4) that is not compatible with Linux' stdcall C functions. > >>>> > >>>> I didn't know Linux even had stdcall C functions. > >>> GCC has __attribute__((__stdcall__)) > >>> Specifically, I want to work with winelib, which is a Windows API > >>> implementation for Linux (and others); and like Windows, uses stdcall. > >> > >> If Linux's stdcall functions are for compatibility with Windows, why > >> aren't they compatible with Windows name mangling? > > > > I don't think that's its one and only purpose. Just what I want it for > > now. Besides, I don't think all Windows compilers mangle stdcall that > > way, and linux ones don't. > > The attached program might help: > 1) use extern(Windows) in your sources > 2) compile > 3) dmd_wine_fixer <your_object_file> > 4) link > > Thomas > > -- Anders |
April 23, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Miller | __attribute__((__stdcall__)) does nothing in gcc on Linux. Windows and Linux do not share the same ABI, so gcc doesn't care about that attribute on non-Windows OS's as far as I know. On 4/23/07, Chris Miller <chris@dprogramming.com> wrote: > On Mon, 23 Apr 2007 03:32:31 -0400, Walter Bright > <newshound1@digitalmars.com> wrote: > > > Chris Miller wrote: > >> How can I make a stdcall function on Linux with DMD? extern(Windows) > >> works, but it gives it DMC's Windows name mangling (e.g. foo@4) that is > >> not compatible with Linux' stdcall C functions. > > > > I didn't know Linux even had stdcall C functions. > > > GCC has __attribute__((__stdcall__)) > > Specifically, I want to work with winelib, which is a Windows API > implementation for Linux (and others); and like Windows, uses stdcall. > > Also, there's a static assert in std.c.windows.windows preventing it from > working with winelib; I had to comment that line out and it at least > compiled, just wouldn't link due to the stdcall stuff. > -- Anders |
April 25, 2007 Re: stdcall functions? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Anders Bergh | On Mon, 23 Apr 2007 17:02:29 -0400, Anders Bergh <anders@andersman.org> wrote:
> __attribute__((__stdcall__)) does nothing in gcc on Linux. Windows and
> Linux do not share the same ABI, so gcc doesn't care about that
> attribute on non-Windows OS's as far as I know.
>
It's doing something here, on 32 bits. I tested it by marking a function definition as stdcall but not its prototype; it linked but did odd things before segfaulting. Matching both without stdcall or both with stdcall made it work as normal.
However, I did notice with 64 bits, gcc will ignore the stdcall attribute.
|
Copyright © 1999-2021 by the D Language Foundation