Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 141859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T07:50:39+00:00 2026-05-11T07:50:39+00:00

Given Microsoft FORTRAN 5.1 and Microsoft C/C++ 14.0, along with the linker that comes

  • 0

Given Microsoft FORTRAN 5.1 and Microsoft C/C++ 14.0, along with the linker that comes with that version of FORTRAN (that must be used for other dependencies) how do I create a C function and call it from the FORTRAN application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T07:50:39+00:00Added an answer on May 11, 2026 at 7:50 am

    You have two choices.
    1) I can show with example

    FORTRAN

    program ftest use iso_c_bindings implicit none interface function saythis(a) ! should be subroutine if saythis returns void import :: c_ptr type(c_ptr), value :: a end function saythis end interface  character(len=80), target :: str type(c_ptr) cstr integer :: r  str='Hello World From Fortran' // C_NULL_CHAR cstr=c_loc(str(1:1)) r=saythis(cstr) 

    C/C++

    #ifdef __cpluscplus #include &ltl;cstdio> using namespace std; #else #inlcude <stdio.h> #endif  #ifdef __GNUC__ #define FORT(func) func ## _ #else #define FORT(func) __stdcall func ## _ #endif  #ifdef __cpluscplus extern 'C' { #endif __declspec(dllexport) int FORT(sayit)(char* c) { return printf('%s\n',c); }  #ifdef __cpluscplus } #endif 

    This works w/gcc toolchain. You’ll have to dumpbin on the DLL and fortran object code to see if the names match up correctly.
    The other way is similar:

    //This is for gcc toolchain //you'll have to find the symbol conversion yourself //I think that Visual Studio converts fortran names //to ALL CAPS so instead of func => _func you'll need func => FUNC 

    FORTRAN

    program ftest integer aa,bb,cc common/vari/aa,bb,cc  aa=7 bb=11 cc=0 call dosomething call dosomethingelse(aa,bb,cc) 

    C/C++

    #ifdef __cplusplus extern 'C' { #endif int _dosomething(); int _dosomethingelse(int*,int*,int*); //all fortran is pass by reference struct { int aa,bb,cc; } vari; #ifdef __cplusplus } #endif  //function def's go here //struct vari should be the same memory as common/vari block 

    COMPILE COMMAND

    $>g++ -c ctest.c <br/> $>gfortran -c ftest.f90 <br/> $>gfortran *.o -lstdc++ -o test_prog <br/> 

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It's been given by Microsoft as a framework design guideline that properties should be
the second function gives error C2803 http://msdn.microsoft.com/en-us/library/zy7kx46x%28VS.80%29.aspx : 'operator ,' must have at least
Given below is my xml: <?xml version=1.0 encoding=utf-8?> <Report xmlns:rd=http://schemas.microsoft.com/SQLServer/reporting/reportdesigner xmlns=http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition> <Body> <ReportItems> <Textbox
What is the wpf equivalent to ControlPaint.Light? http://msdn.microsoft.com/en-us/library/3wz9t9fy%28VS.80%29.aspx Given that WinForms uses System.Drawing.Color and
I have been given two different Microsoft Word document that my virus scanner has
I want to create the webpart in Visual studio 2010/2008 environment with microsoft given
I read news that for game submission for wp7, Microsoft have given a date
I'm currently trying to consume a FORTRAN DLL that I have been given by
I am migrating off of Microsoft's OracleConnection class for a asp.net-mvc website given that
I'm following the Microsoft sample code given for How to create a sink interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.