Silverfrost Forums

Welcome to our forums

VISUAL STUDIO C++ calling FTN95/CLEARWIN

15 Feb 2010 6:57 #5995

I want to be able to call CLEARWIN routines from a Visual Studio C++ program. Since VS C++ appears to only recognise external FTN95 Siverfrost routines I have attempted to set up a simple FTN95 Siverfrost subroutine in VS FTN95/Clearwin as a project using CtoFORTDRAW.f below which is then linked to a VS C++ project using CtoFORT.cpp below. I have followed the Siverfrost example in the Samples/Win32 section in Help but have encoutered many inconsistencies and of course I have not managed to get a successful Build.

The simple programs below work OK in Siverfrost FTN95 and Siverfrost C++ if the commented out pragma library line is added.

Any suggestions.

Martin West

//CtoFORT.cpp Demostrates calling FTN95 Subroutine from a C++ Program //#pragma library 'CtoFORTDRAW.OBJ'

extern 'C' void DRAWLINE(int *x1, int *y1, int *x2, int *y2); int main() { int x1=0; int y1=0; int x2=500; int y2=500;

DRAWLINE(&x1,&y1,&x2,&y2);

}

//============================================== C CtoFORTDRAW.F C See CtoFORT.CPP which calls this routine SUBROUTINE DRAWLINE(x1,y1,x2,y2) INCLUDE <WINDOWS.INS> INTEGER x1,y1,x2,y2 ICNTRL=-1 L=WINIO@('%ww&') L=WINIO@('%ca[CtoFORTDRAW Draw toutine called from C++]&') L=WINIO@('%lw&',ICNTRL) L=winio@('%gr[WHITE]',600,400)

  CALL DRAW_LINE_BETWEEN@(x1,y1,x2,y2,0)

  END
16 Feb 2010 9:09 #6000

Hi Martin

The usual approach would be to use the Silverfrost SCC compiler for C++. If you use the Microsoft compiler in this context then you will be first or one of the few to attempt this. You can therefore expect problems that none of us have seen before or have the time to resolve for you.

16 Feb 2010 9:50 #6003

Paul

Is it possible to call Silverfrost SCC through Visual Studio as a VS project in the same way as a FTN95 project can be set up?

Martin

16 Feb 2010 10:05 #6004

Paul I have tried your sample following Silverfrost instructions and there are inconsistencies as follows The author of this sample supplies two instructions for the treatment of the FORTRAN code.

[1] Set the output file to .lib [2] Select “Extract All”. The author goes on to state that two files are needed, a dll (for run time) and a .lib. Now within Visual C++ 2008, under requirement [1], rather than just a single library, there are two option types: available (a) a static library and (b) an import library. The author’s instructions do not say which of these two library types to choose. Also within Visual C++ 2008 the requirement [2] “Extract All” does not appear.

Now choosing either of the two options (in the VC++ interface) for the output type of the library file results in failure. Now choosing the output type as a dll results in an apparent success (rather than an explicit failure). So presumably the author of the Help section has provided instructions relevant to/for some previous version of VC++.

Can anybody explain what changes to these Help Section instructions are needed to get both outputs in the VC++ 2008 interface?

Martin and Peter

Please login to reply.