Question about beginpaint

Question about beginpaint

Hello,

i am transfering an old CVF program towards IVF (11.1.070).

One construct is not working. I have compilid (i hope) the needed information:

use dfwina
use dfwin
use dflogm

type (T_PAINTSTRUCT) ps
integer(4)     hDlg , hDC

hdc = BeginPaint(hDlg, ps)

error #6633: The type of the actual argument differs from the type of the dummy argument.   [PS]

What has been changed?

Thanks in advance

Frank

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

The code you posted compiles without error in 11.1.078. There's something else you haven't shown us.  As an aside, I would recommend you change the handle declarations to integer(HANDLE) so that they'll be 64-bit ready.

Steve - Intel Developer Support

What about two changes like:

hdc -> needs to be declared as HDC type
hDlg -> needs to be declared as HWND type

ifort doesn't use INTEGER(HDC) and the like because dummy arguments to Windows API functions can have names like 'hdc'. This is more of an acute problem in Fortran than in C because Fortran is case-insensitive and the calling program can use dummy argument names as keywords in function invocations. Thus it matters in Fortran what you actually name the dummy arguments and you can't have a dummy argument declared as

INTEGER(HDC), value :: hdc

Thus ifort just has the

INTEGER, PARAMETER :: HANDLE = C_INTPTR_T

named constant. There are a couple of situations where name collisions were avoided by renaming, like WPARAM and LPARAM are called INTEGER(fWPARAM) and INTEGER(fLPARAM) because Windows callbacks have dummy arguments call wParam and lParam.

@ Steve

You are correct. This is not the complete source code. The source code contains a couple of 10tousand lines. I have only extracted what i thought would be all what is needed. The declaration are located in two files.

the first three in a parent module
use dfwin
use dflogm
integer(4)     hDlg , hDC

The next three in a subroutine where i get the error
use dfwina
type (T_PAINTSTRUCT) ps
hdc = BeginPaint(hDlg, ps)

error #6633: The type of the actual argument differs from the type of the dummy argument.   [PS]

Your suggestion with the integer(handle) would only be needed for hDlg , hDC and for win64byte. Is this correct?

 But from what i get the error?

Unfortunately the intel fortran help excludes all win32 definitions.

Any idea? Thanks in advance

Frank

@ Sergey

i have found the following definition:
public BeginPaint
interface
function BeginPaint(hwnd,lpPaint) bind(C,name='BeginPaint')
use ISO_C_BINDING
use win32_types
implicit none
!GCC$ ATTRIBUTES STDCALL :: BeginPaint
integer(C_INTPTR_T) BeginPaint
integer(C_INTPTR_T), value :: hwnd
type(PAINTSTRUCT_T) lpPaint
end function BeginPaint
end interface

Which comes from a gfortran discussion. Here i have the standard integer definitions for hDlg. I am not sure if this also works with intel fortran.

Frank

That interface body that works in gfortran will only work in ifort in 64-bit mode. Intel does not allow you to mix STDCALL with BIND(C) except in 64-bit mode where STDCALL is the same as CDECL anyway. The KIND numbers here, given as C_INTPTR_T, while correct, would better have been written as HANDLE, so as to be compatible with ifort usage. This doesn't lead to the error message in your previous message, however, because the argument PS, not HDLG, is the one with the wrong type. In the gfortran interface body, the type PAINTSTRUCT_T is referenced, whereas in your ifort code you use the type T_PAINTSTRUCT. These are different in that the former is BIND(C) but not the latter. Actually PAINTSTRUCT_T is just an unfortunate misspelling, but even if that were corrected in module win32_types and user32, your application would fail to link because ifort would try to invoke a CDECL function rather than a STDCALL one. This would work in 64-bit ifort except for your declarations of hDlg and hDC as INTEGER(4) rather than integer(HANDLE). As a general rule, the gfortran interface bodies will work in 64-bit ifort. It's best in ifort to just use IFWIN and hope for the best and change the type names to prepend T_ rather than append _T.

The source you show does not cause an error in 11.1.  Please post a small but complete program that gives you the error.

My suggestion for using INTEGER(HANDLE) was unrelated to your problem - just an observation in passing.

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today