title: Default arguments for pointer in C++ and mixed programming
body: <p>The usage of default arguments for pointers in C++ can be demonstrated with following code </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void myfunc_(int var, double* arr = 0) {
    if (arr == 0) {
      std::cout &lt;&lt; "1 arg" &lt;&lt; std::endl;
    } else {
      std::cout &lt;&lt; "2 arg" &lt;&lt; std::endl;
    }
  }
  
  int main() {
    myfunc(1);
    double *arr = new double[2];
    myfunc(1, arr);
  }
  </code></pre>
  
  <p>in this case, the output of the program is</p>
  
  <pre><code>1 arg
  2 arg
  </code></pre>
  
  <p>on the other hand, if i try to pass optional arguments from Fortran to C++, it does not work. The following example code demonstrates the sutiation</p>
  
  <p>The <strong>myfunc.cpp</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  extern "C" void myfunc_(int var, double* arr = 0) {
    if (arr == 0) {
      std::cout &lt;&lt; "1 arg" &lt;&lt; std::endl;
    } else {
      std::cout &lt;&lt; "2 arg" &lt;&lt; std::endl;
    }
  } 
  </code></pre>
  
  <p>and the <strong>Fortran main program</strong></p>
  
  <pre><code>program main
  use iso_c_binding
  
  real*8 :: arr(2)
  
  call myfunc(1)
  call myfunc(1, arr)
  end program main
  </code></pre>
  
  <p>and the mixed code (Fortran and C++) can be compiled using following command without any error</p>
  
  <pre><code>g++ -c myfunc.cpp
  gfortran -o main.x myfunc.o main.f90 -lstdc++ -lc++ 
  </code></pre>
  
  <p>but the program prints </p>
  
  <pre><code>2 arg
  2 arg
  </code></pre>
  
  <p>in this case. So, Is there any solution for this problem? Am i missing something in here? I think that using default arguments in mixed programming is not working as it expected but i need suggestion at this point.</p>