This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: fortran 2003 and win32api




I just cooked the following up, and it seems to work. I'm sorry to say that I have absolutely no idea how generic the fix is, as I don't really know anything about the win32 calling conventions. (I got the hint of using -Wl,--enable-stdcall-fixup because, if you don't use it, the linker does it for you but issues a very explicit warning).


I have been able to run the example that you send me with good result. The compiler gave: Warning: resolving _Sleep by linking to _ Sleep@4 (without underline!!). In an earlier stage I also did succesfully use another Win32api function (GetModuleHandleA). This message thus indicated the use of the _stdcall convention.

Unfortunately, the seemingly equal simple example with the "Beep" function fails:

 PROGRAM bp
!
 INTERFACE
   FUNCTION Beep(dwFreq,dwDuration) BIND(c, name='Beep')
   USE ISO_C_BINDING
   LOGICAL(c_bool)       :: Beep                  ! 1 byte length
   INTEGER(c_int), VALUE :: dwFreq,dwDuration
   END FUNCTION Beep
 END INTERFACE
!
 LOGICAL(KIND=1) :: bResult_1
!
 bResult_1 = Beep(1000,2000)
!
 END PROGRAM

Running this program yields an undefined reference:

C:\Documents and Settings\van amerongen\Mijn documenten\gf>gfortran -W -Wall -pedantic -std=f2003 bp.f03 -o bp.exe
C:\DOCUME~1\VANAME~1\LOCALS~1\Temp/cc06delE.o:bp.f03:(.text+0x26): undefined reference to `Beep'
collect2: ld returned 1 exit status


So I am afraid there still is something wrong. Tobias Schlüter suggested that there are serious problems as the _stdcall is not supported.
Anyone any suggestion with regard to the application of Win32api and gfortran?


Thanks,
Robert



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]