BetterC and Windows API calls

bauss jacobbauss at gmail.com
Fri Jun 2 19:28:21 UTC 2023


On Friday, 2 June 2023 at 19:19:57 UTC, pineapple wrote:
> I've been experimenting a bit with betterC recently, and I've 
> found that a trivial use of `QueryPerformanceFrequency` (the 
> extern declaration imported from `core.sys.windows.winbase`) 
> immediately crashes my program with status code 3221225477.
>
> https://github.com/pineapplemachine/scamp.d/blob/master/src/scamp/time/monotonic.d#L76
>
> What's going on here? The same code works as expected, without 
> crashing, if I compile without -betterC.
>
> Before this, I found that trying to use the 
> `core.sys.windows.winbase` module's convenience overrides that 
> accept a long pointer instead of a LARGE_INTEGER struct pointer 
> would result in a linker error when compiling with -betterC.
>
> Is there something I need to be doing differently to make 
> Windows API calls, or is this a bug with betterC?

If it works without -betterC and crashes when toggled on, then 
I'm going to assume it's either a bug or memory was corrupted 
before said call to QueryPerformanceFrequency.

Try to isolate the call and see if it crashes with nothing else.


More information about the Digitalmars-d mailing list