F2225, NEAR/FAR Attribute Mismatch

Last reviewed: July 17, 1995
Article ID: Q48787
The information in this article applies to:
  • Microsoft FORTRAN for MS-DOS, versions 4.0, 4.1, 5.0, and 5.1
  • Microsoft FORTRAN for OS/2, versions 4.0, 4.1, 5.0, and 5.1

When using FORTRAN in the large model and calling a subroutine that is declared as NEAR, error F2225 "NEAR/FAR attribute mismatch" is generated if no INTERFACE statement exists for that subroutine.

When the compiler passes a CALL instruction in a large model FORTRAN program, it reserves 4 bytes for the address of the subroutine. If you use the NEAR attribute on the subroutine, only 2 bytes are needed for the subroutine address.

The problem occurs because the compiler assumes the subroutine is type FAR if the compiler reaches the call to the subroutine before the subroutine declaration. If you then specify the subroutine as NEAR, you get the attribute mismatch error.

To eliminate this mismatch, you must use the interface statement at the beginning of the file to explicitly define the subroutine as NEAR, as shown in the following example:

      interface to subroutine mysub [NEAR] ()
      end

This procedure lets the compiler know that when it comes across a call to the subroutine mysub, two bytes should be reserved for the address instead of four bytes.


Additional reference words: kbinf 4.00 4.10 5.00 5.10
KBCategory: kbtool kberrmsg
KBSubcategory: FLIss


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.