Fortran Pre-procesor Query & Feature request

Fortran Pre-procesor Query & Feature request

I need to be able to call the SetClassLongPtr but there is currently no interface for this in the supplied windows modules. I created one myself based upon the definition for SetWindowWord in user32.f90 and it works fine as echoed below.

INTERFACE
FUNCTION SetClassLongPtr( hWnd, nIndex, dwNewLong)
use ifwinty
integer(LONG_PTR) :: SetClassLongPtr ! LONG_PTR
!DEC$ IF DEFINED(_M_IA64) .OR. DEFINED(_M_AMD64) .OR. DEFINED(__x86_64__)
!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'SetClassLongPtrA' :: SetClassLongPtr
!DEC$ ELSE
!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS:'SetClassLongA' :: SetClassLongPtr
!DEC$ ENDIF
integer(HANDLE) hWnd ! HWND hWnd
integer(SINT) nIndex ! int nIndex
integer(LONG_PTR) dwNewLong ! LONG dwNewLong
END FUNCTION
END INTERFACE

However in one project I had the somehow set the preprocessor properties option to Yes (/fpp) instead of No and then the compiler started to complain  that the preprocssor statement was getting an integer value instead of the expected charactor type. Is this expected behavior as the documentation is not  very explicit?

Feature request:  Could SetWindowLongPtr interface be added to the official user32.f90?

Thanks

Steve

8 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

It's a shame that !DEC$ ALIAS seems to require a <i>character-literal</i> rather than a <i>character-initialization-expression</i> which would permit the user to do away with the !DEC$ IF DEFINED stuff that seems to be causing the problems in the first place.

I will see what I can do about getting the interface added.

Please provide more details on the preprocessor issue. If you'd attach a zip of a test case and sample output that would be helpful.

RO, I don't think that would be helpful here.

Steve

INTERFACE 
   FUNCTION SetClassLongPtr( hWnd, nIndex, dwNewLong)
      use ifwinty
      implicit none
      integer(LONG_PTR) :: SetClassLongPtr ! LONG_PTR
      integer, parameter :: nbits = bit_size(0_HANDLE)
! No preprocessor used so there should be no preprocessor errors.
      character(*), parameter :: WinFunName = 'SetClassLong'//trim(merge('PtrA','A   ',nbits==64))
!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE, ALIAS: WinFunName :: SetClassLongPtr
      integer(HANDLE) hWnd ! HWND hWnd
      integer(SINT) nIndex ! int nIndex
      integer(LONG_PTR) dwNewLong ! LONG dwNewLong
   END FUNCTION
END INTERFACE

Steve,

The corresponding GetClassLong/GetClassLongPtr function is not defined in user32.f90 either so if you are able to get the SetClassLongPtr interface introduced perhaps it makes sense to add both together.

Thanks 

Yes, I intend to look at all of these.  There are lots and lots of new API routines we are missing. Adding these is not trivial but we're doing what we can.

Steve

Thanks Steve, I understand that any mods require a lot of testing and validation work. 

The testing and validation is work, to be sure, but discovering which APIs are new or changed, and building the Fortran equivalents, that's the most time-consuming. We've tried automated tools but they only get us so far.

Steve

Login to leave a comment.