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

Fortran pointer's Interpretation.

dzuba
Beginner
616 Views
Hello!

I nave created a handle for the WM_COPYDATA message.
wParam and lPatam have type of integer in message handler process.
But actually lPatam is a pointer to a

COPYDATASTRUCT {
ULONG_PTR dwData;
DWORD cbData;
PVOID lpData;
}

lpData is a pointer to a data I need. So, how can I get access to it? Thow to read passed data? The passed data is an array of real*4.

Thanks.
0 Kudos
2 Replies
Jugoslav_Dujic
Valued Contributor II
616 Views
Until Intel implements Fortran 2003-standard ISO_C_BINDING module, which is supposed to provide portable cross-language bindings, you have to resort to "integer" pointers (aka "Cray pointers"). They're described in documentation as "Integer pointers".

Briefly, a Cray pointer has two components: a pointer (which corresponds to C void*/LPVOID) and a pointee (which can be of any type). When the pointer is assigned a value (an address), the pointee is "automagically" "equivalenced" with the pointed-to address.

In your case (I prefer to declare both pointee and the pointer in one-line separated by semicolon):
type(T_COPYDATASTRUCT):: CDS; pointer(pCDS, CDS)
real:: MyData(*); pointer(pMyData, MyData)
...
case(WM_COPYDATA)
  pCDS = lParam   !CDS now points to (COPYDATASTRUCT*)lParam
  pMyData = CDS%lpData
  DO i=1,n
     foo = MyData(i)
  END DO

Message Edited by JugoslavDujic on 03-15-2006 05:15 PM

0 Kudos
dzuba
Beginner
616 Views
Thank You!
0 Kudos
Reply