foreach range construction bug?!!?!?!?

Phil Lavoie maidenphil at hotmail.com
Mon Jan 7 06:55:13 PST 2013


On Monday, 7 January 2013 at 09:16:00 UTC, Mike Parker wrote:
> On Monday, 7 January 2013 at 07:57:39 UTC, Tavi Cacina wrote:
>> Am 06.01.2013 19:59, schrieb Phil Lavoie:
>>> Now here is what is really troubling me, the non defined 
>>> version (using
>>> the import library) crashes when the range constructor is 
>>> called inside
>>> the foreach statement, which is weird by itself. In addition, 
>>> in DOES
>>> NOT crash when the functions are artifically defined. Anyone 
>>> seen that
>>> before? Or maybe I am doing something wrong?
>>>
>>
>> I had once some crashes when calling code in an external dll 
>> (on Windows). The problem went away after I've changed the 
>> declaration from extern(C) to extern(System). It may be worth 
>> trying.
>>
>> Tavi.
>
> As a general solution, that's not good advice, but in this case 
> it's probably so. The OpenGL functions on Windows are declared 
> with the stdcall calling convention, and as cdecl on other 
> platforms. In D code, that means they need to be declared as 
> extern(Windows) on Windows and extern(C) everywhere else. 
> extern(System) is the convenient way to do that, as the 
> compiler will do the right thing on each platform. Always look 
> at the C headers to understand how the functions are declared 
> before declaring them in D to make sure you've got the correct 
> calling convention.

Yeah you're right, though I'm having difficulty making the import 
library.
implib /noi /system will generate "_name" function names, but 
extern windows
expect them to be "_name at someInt". Removing system only seems to 
remove the prepended "_". Any ideas?


More information about the Digitalmars-d-learn mailing list