title: GNU Fortran - controlling symbol case
body: <p>Is there a way to control the case of symbols emitted by GNU Fortran 4.8?</p>
  
  <p>Older versions (such as 3.4) had <code>-fcase-lower</code>, <code>-fcase-preserve</code> and <code>-fcase-upper</code> to force lower case, the case used in the source and upper case respectively, but these seem to have been discarded.  Is there some new way of controlling this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I'm trying to port a large, mixed C/Fortran, code base from Intel compilers to GNU compilers.</p>
  
  <p>I'm aware that we can use <code>BIND(C, name='...')</code> to give a case-specific symbol name.  However, that has other effects.  Consider this C function:</p>
  
  <pre><code>void print(char *str, size_t len) {
      for(int ii = 0; ii &lt; len; ii++) {
          putchar(str[ii]);
      }
      putchar('\n');
  }
  </code></pre>
  
  <p>We can call it from a Fortran program like this:</p>
  
  <pre><code>program test
      implicit none
      interface
          subroutine printstr(str)
              character :: str(*)
          end subroutine
      end interface
  
      call printstr("Hello, world.");
  end
  </code></pre>
  
  <p>If the C function name is not all lower-case (<code>PrintStr</code>, say) then we might try to fix the Fortran program like this:</p>
  
  <pre><code>program test
      implicit none
      interface
          subroutine printstr(str) bind(C, name='PrintStr')
              use iso_c_binding
              character :: str(*)
          end subroutine
      end interface
  
      call printstr("Hello, world.");
  end
  </code></pre>
  
  <p>This doesn't work, though, because the <code>bind(C, ...)</code> changes how the string parameter is handled and the length parameter is no longer provided (I'm not sure if this results in stack corruption or just buffer overruns - the example given always segfaults from the buffer overrun).</p>
  
  <p>I think it's probably time for a fresh question on how to sort this out.</p>