Forum > General
What compiler option causes an implied "stdcall" in Win32 ?
(1/1)
440bx:
Hello,
The title says it all but, here are some details. Note: the following applies to 32bit. In func.inc "CompareFileTime" is defined as follows (note the absence of "stdcall").
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function CompareFileTime(lpFileTime1:LPFILETIME; lpFileTime2:LPFILETIME):LONG;external 'kernel32' name 'CompareFileTime';In the process of "porting" some Delphi 2.0 programs, I ran into the fact that Delphi 2.0 has a different definition for that function and proceeded to make one that I thought was equivalent from a copy/paste of FPC's original definition. I ended up with this:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function CompareFileTime(constref lpFileTime1:TFILETIME; constref lpFileTime2:TFILETIME):LONG;external 'kernel32' name 'CompareFileTime';which promptly rewarded me with a SIGSEGV.
Inspecting the assembly code revealed that my definition was passing the parameters in registers instead of on the stack. Adding "stdcall" to the definition solved the problem.
What I am puzzled about is that the definition in "func.inc" does _not_ state "stdcall" yet, it works. What compiler directive (or anything else) caused the compiler to automatically consider the definition "stdcall" ?
(Note: I do not have any compiler mode set in the program - only directive present is {$APPTYPE GUI}) Also, this is under Win7 64bit, using FPC v3.0.4.
Thank you for your help.
marcov:
In rtl/win<xx>/windows.pp
{$calling stdcall}
440bx:
--- Quote from: marcov on February 14, 2019, 10:08:22 am ---In rtl/win<xx>/windows.pp
{$calling stdcall}
--- End quote ---
Thank you Marco. I knew there had to be some setting somewhere that told the compiler to use "stdcall" but, I could find it.
Thaddy:
Or - more in general - from the command line -Cc<x> Set default calling convention to <x>
Navigation
[0] Message Index