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

fortran 77 routine in VS c++ v.6.0

lombardig2
Beginner
988 Views
The questions are:
1) I built a mixed program Project into Visual Studio c++ 6.0. In order to link the all project (a main cpp, object cpp, subroutin f77) I didn't use ___stdcall for calling fortran subroutine and I remove /Gz from options of Fortran compiler. Otherwise I Keep /Gz in fortran compiler 's options, everything is ok. But if I write:
extern "C" void __stdcall CMPROOT(fdcomplexnum* num);
I got the error message
error LNK2001: unresolved external symbol _CMPROOT@4
SO which is the right procedure, choice of options to keep __stdcall in the code? {this is for compatibility with other compilers)
2) When I used Compact Visual Fortran 5 I had color utilities to recognize fortran code. How can I get it in Visual c++ 6.0 while I am using Intel Fortran compiler?

thank you Guido Lombardi
0 Kudos
7 Replies
Steven_L_Intel1
Employee
988 Views
Intel Fortran does not use STDCALL as the default calling mechanism. I think you want to take out the __stdcall and not use /Gz. (If I am understanding you properly.)

You cannot get Fortran source coloring in the VC6 environment with Intel Fortran. You will get it in the VC.NET environment with Intel Fortran 7.x.

Steve
0 Kudos
lombardig2
Beginner
988 Views
Thank you,

so the right way to mix code is removing the __stdcall from c header (that I need to call the frotran routine from C) and removing /Gz from the fortran compiler, is it?

Guido Lombardi
0 Kudos
Steven_L_Intel1
Employee
988 Views
If I correctly understand what you have, yes.

Steve
0 Kudos
Jugoslav_Dujic
Valued Contributor II
988 Views
A side note: a nicer way is to have
#define FORTRAN_CALL __cdecl
...
extern "C" void FORTRAN_CALL FortranRoutine(...
Jugoslav
0 Kudos
TimP
Honored Contributor III
988 Views
This is not the first time the wording of the documentation has created confusion. /Gm is the version of __stdcall which works with Fortran 77 in general, as well as matching the default usage of CVF, but you wouldn't know it from the documentation. /Gz doesn't support CHARACTER arguments in a workable way. jugoslavdujic makes a good suggestion, which will work with Windows-ia64 as well, where Microsoft doesn't support __stdcall.
0 Kudos
lombardig2
Beginner
988 Views
I am getting confused:
My working solution is:
first solution:
1) without /Gz, /Gm
2) extern "C" void FortranRoutine(...);
or
extern "C" void __cdecl FortranRoutine(...);
first solution:
1) without /Gz, with /Gm
2) extern "C" void __stdcall FortranRoutine(...);

What is the right way to mix code in vc++ 6 with c++ code (main, routine) and fortran (routine)?

thank you,

Guido
0 Kudos
Jugoslav_Dujic
Valued Contributor II
988 Views
Both are correct. I only suggested introducing a #define in C++ code so that you can change it in one place if/when you change the Fortran compiler/compiler option/OS and make code more readable -- an aesthetical rather than essential remark. Tim just commented that the documentation was less than ideal on the /Gm-/Gz subject.

Jugoslav
0 Kudos
Reply