Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Novice
59 Views

Calling Microsoft C++ from Intel Visual Fortran

What is the best way to call a Microsoft C++ routine from Intel Visual Fortran? I would prefer to create a MS C++ library and then link it into my application and call it direct rather than making a C++ DLL and then calling the DLL.

0 Kudos
5 Replies
Highlighted
Black Belt
59 Views

That's a pretty broad question. You can do what you prefer (C++ static library that a Fortran program links to, or vice versa). Is there some particular aspect that you want more information on?
 

0 Kudos
Highlighted
Novice
59 Views

Apologies if it was too broad. I would prefer a MS C++ static library that I would just call from Intel Fortran. I would just set up a data structure in the Fortran and pass its pointer to the C++ routine which would contain an equivalent structure. How to pass the data back and forth is not a problem.

The main thing I'm unsure about is what pragmas, etc are required in the Fortran and C++ so that they link and communicate with each other properly.

0 Kudos
Highlighted
Black Belt
59 Views

Declare the C++ function with extern "C", use BIND(C) on the Fortran side, and in general away you go...

0 Kudos
Highlighted
Black Belt
59 Views

For usage of BIND(C) there are useful examples you can find by search engines (perhaps as ISO C interop).  Fortunately, this is an aspect of Fortran which generally is treated accurately.  Multiple rank arrays aren't so pretty.

0 Kudos
Highlighted
Honored Contributor I
59 Views

schulzey wrote:

Apologies if it was too broad. I would prefer a MS C++ static library that I would just call from Intel Fortran. I would just set up a data structure in the Fortran and pass its pointer to the C++ routine which would contain an equivalent structure. How to pass the data back and forth is not a problem.

The main thing I'm unsure about is what pragmas, etc are required in the Fortran and C++ so that they link and communicate with each other properly.

See this thread on this forum, quote #6 for an example:

https://software.intel.com/en-us/forums/intel-visual-fortran-compiler-for-windows/topic/699941

0 Kudos