Software Archive
Read-only legacy content

_stdcall

Intel_C_Intel
Employee
641 Views
Have simple mixed c++ main call to fortran subroutine working, but calling multiple subroutines from the same cmain.cpp is "different."

two separate function statements in c++ main to the fortran subroutines as
extern void _stdcall IADDTWO (long *i,long *j,long *k);
and
extern void _stdcall FSUB (double *c);
generate an
error LNK2001: unresolved external symbol "void __stdcall FSUB(double *)" (?FSUB@@YGXPAN@Z)

roughly the same thing occurs on reordering the statements:
error LNK2001: unresolved external symbol "void __stdcall IADDTWO(long *,long *,long *)" (?IADDTWO@@YGXPAJ00@Z)

running the cmain.cpp program with only a call to one or the other fortran routine works fine.

Alternatively, parsing the statement as
extern void _stdcall FSUB (double *c), IADDTWO (long *i,long *j,long *k);
alone has a successful link and "run." "run" is in quotes for the console application because the "illegal operation" message box activates. On closing the box, the program seems to terminate normally.

Guessing that directly aliasing the functions may work, but even if it does I'd like to understand what's going on with calls noted.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
641 Views
C++ name mangling. Use:

extern "C" void ...

instead. This is discussed in the mixed-language programming chapter of the Programmer's Guide.

Steve
0 Kudos
Intel_C_Intel
Employee
641 Views
Don't know much about mixed programming,
Don't know much about extern "C"

But it seemed to work from the call indicated in a recent string call discussion:
Reply From: Jugoslav Dujic
February 12,2002 6:15am

For the previous two _stdcall query, the following two statements work and the program terminates properly:

extern void _stdcall FSUB (double *c);
extern "C" void _stdcall IADDTWO (long *i,long *j,long *k);

Note that the standard

#ifdef __cplusplus
extern "C"
#endif

was invoked above the void function statement. The second forced reference worked and no aliasing was necessary in the fortran subroutine(s).

Thank you, Mr. Dujic et. al.
0 Kudos
Reply