September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | On 5 September 2011 08:31, S?nke Ludwig
<ludwig at informatik.uni-luebeck.de> wrote:
> Am 04.09.2011 20:57, schrieb Walter Bright:
>>
>>
>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>>
>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is
>>> declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was
>>> getting errors that did not occur before.
>>>
>>
>> What should it be declared as?
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
> Should be extern(C)
Are you sure? My understanding was that there was only one extern(C)
function in the entire Windows API (it's extern(C) because it uses
varargs).
__stdcall normally means extern(Windows).
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | On 05.09.2011 08:31, S?nke Ludwig wrote:
> Am 04.09.2011 20:57, schrieb Walter Bright:
>>
>>
>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was getting errors that did not occur before.
>>>
>>
>> What should it be declared as?
>>
> Should be extern(C)
__stdcall translates to extern(Windows), so I'd say core.sys.windows.windows is correct.
Until very recently, the calling convention was not verified, so it is probably a bug in your code. The fix also revealed an issue where the signature was different in my code, but the compiler did not complain when assigning function pointers.
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | On Mon, Sep 5, 2011 at 4:31 PM, S?nke Ludwig
<ludwig at informatik.uni-luebeck.de> wrote:
> Am 04.09.2011 20:57, schrieb Walter Bright:
>>
>>
>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>>
>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is
>>> declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was
>>> getting errors that did not occur before.
>>>
>>
>> What should it be declared as?
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
> Should be extern(C)
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
extern(Windows) == __stdcall
The errors you're getting might be due bug 3797 being fixed. (broken
implicit conversions)
Can you post them?
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | Am 05.09.2011 08:31, schrieb S?nke Ludwig:
> Am 04.09.2011 20:57, schrieb Walter Bright:
>>
>>
>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was getting errors that did not occur before.
>>>
>>
>> What should it be declared as?
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
> Should be extern(C)
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
Arrg, sorry I switched the terms!
CALLBACK is actually defined as > __cdecl < in contrast to the other API functions which are __stdcall!
I will check the other callback aliases as well so see which have CALLBACK.
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | On 5 September 2011 09:28, S?nke Ludwig
<ludwig at informatik.uni-luebeck.de> wrote:
> Am 05.09.2011 08:31, schrieb S?nke Ludwig:
>>
>> Am 04.09.2011 20:57, schrieb Walter Bright:
>>>
>>>
>>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>>>
>>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is
>>>> declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was
>>>> getting errors that did not occur before.
>>>>
>>>
>>> What should it be declared as?
>>> _______________________________________________
>>> dmd-beta mailing list
>>> dmd-beta at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>
>> Should be extern(C)
>> _______________________________________________
>> dmd-beta mailing list
>> dmd-beta at puremagic.com
>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
> Arrg, sorry I switched the terms!
>
> CALLBACK is actually defined as > __cdecl < in contrast to the other API functions which are __stdcall!
Where did you read that? It's __stdcall.
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | http://msdn.microsoft.com/en-us/library/aa383751(v=vs.85).aspx says CALLBACK == __stdcall, which is what I'd expect. On Mon, Sep 5, 2011 at 5:28 PM, S?nke Ludwig <ludwig at informatik.uni-luebeck.de> wrote: > Am 05.09.2011 08:31, schrieb S?nke Ludwig: >> >> Am 04.09.2011 20:57, schrieb Walter Bright: >>> >>> >>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote: >>>> >>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is >>>> declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was >>>> getting errors that did not occur before. >>>> >>> >>> What should it be declared as? >>> _______________________________________________ >>> dmd-beta mailing list >>> dmd-beta at puremagic.com >>> http://lists.puremagic.com/mailman/listinfo/dmd-beta >> >> Should be extern(C) >> _______________________________________________ >> dmd-beta mailing list >> dmd-beta at puremagic.com >> http://lists.puremagic.com/mailman/listinfo/dmd-beta > > Arrg, sorry I switched the terms! > > CALLBACK is actually defined as > __cdecl < in contrast to the other API functions which are __stdcall! > > I will check the other callback aliases as well so see which have CALLBACK. > > _______________________________________________ > dmd-beta mailing list > dmd-beta at puremagic.com > http://lists.puremagic.com/mailman/listinfo/dmd-beta > |
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Am 05.09.2011 09:53, schrieb Don Clugston:
> On 5 September 2011 09:28, S?nke Ludwig
> <ludwig at informatik.uni-luebeck.de> wrote:
>> Am 05.09.2011 08:31, schrieb S?nke Ludwig:
>>> Am 04.09.2011 20:57, schrieb Walter Bright:
>>>>
>>>> On 9/4/2011 3:44 AM, S?nke Ludwig wrote:
>>>>> Just a small thing.. at least TIMERPROC in core.sys.windows.windows is
>>>>> declared as extern(Windows) (CALLBACK is defined as __stdcall in C). I was
>>>>> getting errors that did not occur before.
>>>>>
>>>> What should it be declared as?
>>>> _______________________________________________
>>>> dmd-beta mailing list
>>>> dmd-beta at puremagic.com
>>>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>>> Should be extern(C)
>>> _______________________________________________
>>> dmd-beta mailing list
>>> dmd-beta at puremagic.com
>>> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>> Arrg, sorry I switched the terms!
>>
>> CALLBACK is actually defined as > __cdecl < in contrast to the other API functions which are __stdcall!
> Where did you read that? It's __stdcall.
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
I was searching on MSDN, but that one obviously states __stdcall. I think I was somehow falsely reinforced in thinking is is __cdecl because my (buggy) code does not crash. But actually it doesn't crash just because the windows function calls the callback as its last action and then uses EBP to restore the stack pointer...
Many apologies for the confusion!
|
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | Am 04.09.2011 06:48, schrieb Walter Bright: > http://ftp.digitalmars.com/dmd1beta.zip > http://ftp.digitalmars.com/dmd2beta.zip > _______________________________________________ > dmd-beta mailing list > dmd-beta at puremagic.com > http://lists.puremagic.com/mailman/listinfo/dmd-beta Has anything changed with regard to TLS? I'm getting OutOfMemoryErrors when accessing TLS arrays from within a DLL. Maybe the dll_fixTLS function in core.sys.windows.dll needs to be adjusted? --- import std.c.windows.windows; import core.sys.windows.dll; int[] s_arr; extern (Windows) BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { switch (ulReason) { default: return false; case DLL_PROCESS_ATTACH: if( !dll_process_attach( hInstance, true ) ) return false; s_arr ~= 0; // -> OutOfMemoryError break; } return true; } --- -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20110905/8982f99a/attachment.html> |
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig | What OS are you running on? Your code works for me (XP SP3). Also Visual D works fine AFAICT (its a plugin DLL to VS). On 05.09.2011 19:17, S?nke Ludwig wrote: > Am 04.09.2011 06:48, schrieb Walter Bright: >> http://ftp.digitalmars.com/dmd1beta.zip >> http://ftp.digitalmars.com/dmd2beta.zip >> _______________________________________________ >> dmd-beta mailing list >> dmd-beta at puremagic.com >> http://lists.puremagic.com/mailman/listinfo/dmd-beta > Has anything changed with regard to TLS? > > I'm getting OutOfMemoryErrors when accessing TLS arrays from within a DLL. Maybe the dll_fixTLS function in core.sys.windows.dll needs to be adjusted? > > --- > import std.c.windows.windows; > import core.sys.windows.dll; > > int[] s_arr; > > extern (Windows) > BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) { > switch (ulReason) { > default: return false; > case DLL_PROCESS_ATTACH: > if( !dll_process_attach( hInstance, true ) ) return false; > s_arr ~= 0; // -> OutOfMemoryError > break; > } > return true; > } > --- > > > _______________________________________________ > dmd-beta mailing list > dmd-beta at puremagic.com > http://lists.puremagic.com/mailman/listinfo/dmd-beta -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.puremagic.com/pipermail/dmd-beta/attachments/20110905/167ab4a6/attachment.html> |
September 05, 2011 [dmd-beta] dmd 1.070 and 2.055 beta | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sönke Ludwig |
On 9/5/2011 2:49 AM, S?nke Ludwig wrote:
>
> Many apologies for the confusion!
>
No problem. This stuff *is* confusing. Glad that issue got cleared up.
|
Copyright © 1999-2021 by the D Language Foundation