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

fortran interface for 'void func (void * foo)' ?

uhbarney
Einsteiger
882Aufrufe
I'm porting a large mixed language product to run under NT. Some source files are in Fortran, some in C. I've managed to generate Fortran prototypes for most of the C functions, but I don't know how to deal with 'void*' arguments as in:

void func (void * foo);

Of course, the intent is to be able to provide the function with any type of argument by reference without compiler complaint.

My latest thoughts are to somehow use a Fortran pointer when calling such a C function, but I'm not sure which pointer type to use, or how to best arrange things. Any advice out there?
0 Kudos
3 Antworten
james1
Einsteiger
882Aufrufe
That would be something like

SUBROUTINE FUNC (FOO)
INTEGER(POINTER_LEN) FOO

and calling like

CALL FUNC (LOC(blob))

James
Steven_L_Intel1
Mitarbeiter
882Aufrufe
In James' example, replace

POINTER_LEN

with

INT_PTR_KIND()

Steve
james1
Einsteiger
882Aufrufe
Or do a

USE DFWINTY

to define POINTER_LEN. I personally like the look of

INTEGER(POINTER_LEN)

a little better than

INTEGER(INT_PTR_KIND())

James
Antworten