title: Compilation on Linux/Mac but NOT in Windows - C++ with C, C++ and Fortran
body: <p>This is a simple, <strong>main C++ program with a C, C++ and a Fortran</strong> function inside.</p>
  
  <p>I am <strong>only able to compile the code on Linux, but not on Windows</strong> however.</p>
  
  <p>The code runs as intended on Linux but <strong>in Windows the program compiles fine but freezes</strong> when the simple Fortran output is shown.</p>
  
  <p>Could you show me what might cause this error?</p>
  
  <p>Each of the C, C++ and Fortran functions simply sets variables a and b to specific values:</p>
  
  <p>ffunction.f:</p>
  
  <pre><code>  subroutine ffunction(a,b)
    a=3.0
    b=4.0
    end
  </code></pre>
  
  <p>cfunction1.c:</p>
  
  <pre><code>void cfunction1(float *a, float *b) {
      *a=7.0;
      *b=8.0;
  }
  </code></pre>
  
  <p>cppfunction1.c:</p>
  
  <pre><code>void cppfunction1(float *a, float *b) {
      *a=7.0;
      *b=8.0;
   }
  </code></pre>
  
  <p>cppprogram.C:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  extern "C" {
    void ffunction_(float *a, float *b);
  }
  
  extern "C" {
    void cfunction1(float *a, float *b);
  }
  
  void cppfunction1(float *a, float *b);
  
  int main() {
    float a=1.0, b=2.0;
  
    cout &lt;&lt; "Before running Fortran function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    ffunction_(&amp;a,&amp;b);
  
    cout &lt;&lt; "After running Fortran function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    cout &lt;&lt; "Before running C function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    cfunction1(&amp;a,&amp;b);
  
    cout &lt;&lt; "After running C function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    cout &lt;&lt; "Before running C++ function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    cppfunction1(&amp;a,&amp;b);
  
    cout &lt;&lt; "After running C++ function:" &lt;&lt; endl;
    cout &lt;&lt; "a=" &lt;&lt; a &lt;&lt; endl;
    cout &lt;&lt; "b=" &lt;&lt; b &lt;&lt; endl;
  
    return 0;
  }
  </code></pre>