PRB: C Code Cannot Access Data From FORTRAN COMMON Block
PSS ID Number: Q11665
Article last modified on 02-09-1993

3.30

MS-DOS


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft FORTRAN for MS-DOS, version 3.3
----------------------------------------------------------------------

Summary:

SYMPTOMS
   In a mixed-language application, an attempt to access the contents
   of a FORTRAN COMMON block from a C module fails. An "unresolved
   external" error may occur.

CAUSE
   The compiler does not change the name of the COMMON block to
   lowercase letters nor does it place a leading underscore on the
   name. An attempt to use the ALIAS attribute also fails; the name is
   truncated or set to blanks.

RESOLUTION
   To work around this problem, modify the source code to pass the
   variables to the C code as arguments rather than passing the
   variables through the COMMON block.

STATUS
   Microsoft has confirmed this to be a problem in FORTRAN version 3.3
   for MS-DOS. This problem was corrected in FORTRAN version 3.31 for
   MS-DOS.

More Information:

Page 105 of the Microsoft FORTRAN "User's Guide" for version 3.3
includes the following statement:

   If you specify the C attribute on ... a named common block in
   FORTRAN, the name is changed to lowercase and a leading underscore
   is added.

The error occurs because the FORTRAN version 3.3 does not modify the
name of the COMMON block when it has the C attribute. The following
code example demonstrates this problem.

Sample Code
-----------

C Compile options needed: None

      SUBROUTINE TEST
      COMMON /STMT [C]/ J(3)
      J(1) = 3
      J(2) = 5
      J(3) = 8
      STOP
      END

Additional reference words: 3.30

=============================================================================

Copyright Microsoft Corporation 1993.
