Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29276 Discussions

error #6683: A kind type parameter must be a compile-time constant

Brooks_Van_Horn
New Contributor I
6,776 Views

I'm using the free Visual Studio 2013 with my Intel 2016 Fortran Compiler and I get the error #6683. Here is a code segment (just a part of my code) that demonstrates the errors:

interface
   integer*4 function CreateWindowEx (dwExStyle,lpClassName,lpWindowName,dwStyle,     &
                                      x, y, nWidth, nHeight, hWndParent, hMenu,       &
                                      hInstance, lpParam )
     !DEC$ ATTRIBUTES STDCALL, ALIAS : 'CreateWindowEx' :: CreateWindowEx
     use IFWIN
     Integer(DWORD),intent(in)::  dwExStyle
     Integer(LPCTSTR),intent(in)::   lpClassName
     . . . more after this


error #6683: A kind type parameter must be a compile-time constant.   [LPCTSTR]
            Integer(LPCTSTR),intent(in)::   lpClassName
           ------------^

If I declare the function to return a HWND then it gets an error too.

 

Brooks V

0 Kudos
1 Solution
JVanB
Valued Contributor II
6,776 Views

Ouch, that interface body hurts my eyes! If you are going to USE IFWIN, just go with the explicit interface for CreateWindowEx that IFWIN already provides through user32. integer*4 is wrong, as it should be integer(HANDLE). The alias should be CreateWindowExA. ifort doesn't provide separate parameters like HWND because some of the Win32 API functions have dummy arguments with names like hWnd distinguishable only by case in C, so it would be complicated if HWND was a named constant in Fortran. Just use HANDLE for all those things except for HFILE. I suggest you look at user32.f90 in Intel's include directory for a tutorial on how to write those interface bodies.

Edit: I didn't see mecej4's reply. IFWIN already uses IFWINTY; if you USE IFWIN, you are pretty much using everything.

 

View solution in original post

0 Kudos
7 Replies
mecej4
Honored Contributor III
6,776 Views

Many of the Windows type objects such as LPCSTR, etc., are not standard Fortran (sometimes not even standard C) intrinsic types, so you have to USE a module such as winty or include a declarations .h or .inc file that supplies definitions for them, or roll your own type declarations that match those used by Microsoft C.

0 Kudos
JVanB
Valued Contributor II
6,777 Views

Ouch, that interface body hurts my eyes! If you are going to USE IFWIN, just go with the explicit interface for CreateWindowEx that IFWIN already provides through user32. integer*4 is wrong, as it should be integer(HANDLE). The alias should be CreateWindowExA. ifort doesn't provide separate parameters like HWND because some of the Win32 API functions have dummy arguments with names like hWnd distinguishable only by case in C, so it would be complicated if HWND was a named constant in Fortran. Just use HANDLE for all those things except for HFILE. I suggest you look at user32.f90 in Intel's include directory for a tutorial on how to write those interface bodies.

Edit: I didn't see mecej4's reply. IFWIN already uses IFWINTY; if you USE IFWIN, you are pretty much using everything.

 

0 Kudos
Steven_L_Intel1
Employee
6,776 Views

IFWIN defines LPCSTR but not LPCTSTR. Nevertheless, go with Repeat Offender's recommendation and use the CreateWindowEx declaration we provide that allows for CHARACTER arguments.

0 Kudos
Brooks_Van_Horn
New Contributor I
6,776 Views

OK!  But what is a good reference for which use programs define which labels?

Brooks V

0 Kudos
Steven_L_Intel1
Employee
6,776 Views

Well, the best reference is the topic "Using the Windows API Routines" in the Compiler Reference.  https://software.intel.com/en-us/compiler_winapp_f is also useful. But these don't go into quite that level of detail. It often helps to open ifwinty.f90 (in the compiler's Include folder) in a text editor, and for function declarations, the appropriate module source such as user32.f90 to study the interface shown. 

I'd also recommend looking through the various samples provided, especially the ones in Win32.zip.

0 Kudos
andrew_4619
Honored Contributor III
6,776 Views

If I want to check the Fortran declarations then using CreateWindowEx as and example:

1) Look at the MSDN referance page e.g. https://msdn.microsoft.com/en-gb/library/windows/desktop/ms632680%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

2) In the table at the end of the article you will see this API is in the USER32 library

3) Goto C:\Program Files (x86)\Intel\Composer XE 2015\compiler\include (or whatever your version is) and Open USER32.f90.

4) Find the CreateWindowEx entry and in the interface you will see the inferdface types used by IFORT,.

Simples

0 Kudos
Brooks_Van_Horn
New Contributor I
6,775 Views

Thanks all. Consider this closed.

0 Kudos
Reply