Re: SetPriorityClass
- From: garylscott@xxxxxxxxxxxxx
- Date: Tue, 15 Jan 2008 07:40:21 -0800 (PST)
On Jan 15, 9:03 am, Steve Lionel <steve.lio...@xxxxxxxxx> wrote:
On Jan 15, 4:36 am, tho...@xxxxxxxxxxxx wrote:
The problem is solved. Thanks. Part of me says that no additional
information is needed, because I have what I wanted. Another part of
me wants to know why the inclusion of USE KERNEL32 suddenly allowed
the linker to resolve the external reference to SetPriorityClass.
Usually an unresolved external means that one didn't specify the right
library to the linker, but in this case I made no changes to the
library list, so I am a bit puzzled as to why it now links.
If you had posted the text of the linker error message, it would have
said that _SETPRIORITYCLASS was undefined, because the defaults in
Intel Fortran for Windows are that routines have the C calling
convention and the names are upcased. However, the Win32 API routines
use the STDCALL calling convention and their names are mixed case, so
the name provided in kernel32.lib is _SetPriorityClass@8 which does
not match _SETPRIORITYCLASS.
Intel Visual Fortran provides a large number of predefined modules for
Win32 API declarations. Think of them as the same as the various
header files provided by MSVC, such as windows.h. These contain
declarations of constants, types and routines in the Win32 API to
enable easy use from Fortran. In the case of SetPriorityClass, an
interface block is provided as follows:
INTERFACE
FUNCTION SetPriorityClass( &
hProcess, &
dwPriorityClass)
import
integer(BOOL) :: SetPriorityClass ! BOOL
!DEC$ ATTRIBUTES DEFAULT, STDCALL, DECORATE,
ALIAS:'SetPriorityClass' :: SetPriorityClass
integer(HANDLE) hProcess ! HANDLE hProcess
integer(DWORD) dwPriorityClass ! DWORD dwPriorityClass
END FUNCTION
END INTERFACE
INTERFACE
This declares the routine and arguments (also making sure that you
pass the correct number and types of arguments), and changes the
calling convention and external name to match that of the actual
routine.
As you found, there are some named constants defined for common Win32
datatypes, to be used as kind specifiers. These correspond,
generally, to those documented by Microsoft for the Win32 API. HANDLE
is one of them. Yes, you may have a name that conflicts with one of
the symbols from the module. You can use ONLY or renaming clauses if
this is an issue, or take the other approach and rename your
identifier.
By the way, you don't need to also USE IFWINTY, as this is implied by
USE KERNEL32.
Really, this is no different from the use of header files in C/C++.
You don't HAVE to use them, but if you don't you'll generally need to
"roll your own" substitute declarations to get the right semantics.
I suggest you read the Intel Fortran documentation on use of the Win32
API.
I also repeat my suggestion that the Intel Visual Fortran user forum
is a better place for a question such as this, as it is specific to a
vendor. I know that such topics are common here, but that doesn't
mean this newsgroup is the best place for them.
Steve Lionel
Developer Products Division
Intel Corporation
Nashua, NH
User communities for Intel Software Development Products
http://softwareforums.intel.com/
Intel Fortran Support
http://support.intel.com/support/performancetools/fortran
My Fortran blog
http://www.intel.com/software/drfortran
P.S. STDCALL was originally called PASCAL.
.
- References:
- SetPriorityClass
- From: tholen
- Re: SetPriorityClass
- From: Steve Lionel
- Re: SetPriorityClass
- From: tholen
- Re: SetPriorityClass
- From: Steve Lionel
- SetPriorityClass
- Prev by Date: Re: SetPriorityClass
- Next by Date: A question about "kind"?
- Previous by thread: Re: SetPriorityClass
- Next by thread: Re: SetPriorityClass
- Index(es):
Relevant Pages
|
|