Microsoft KB Archive/49466

= Conditionally Compiling Metacommands in FORTRAN Code =

Article ID: 49466

Article Last Modified on 12/1/2003

-

APPLIES TO


 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1
 * Microsoft FORTRAN PowerStation 1.0 Standard Edition
 * Microsoft Fortran PowerStation 1.0a for MS-DOS
 * Microsoft FORTRAN PowerStation 32
 * Microsoft FORTRAN PowerStation 32
 * Microsoft FORTRAN Compiler 5.0
 * Microsoft FORTRAN Compiler 5.1

-



This article was previously published under Q49466



SUMMARY
You can conditionally compile metacommands in FORTRAN source code. However, you cannot use the /4cc compiler option switch to do so because the metacommand requires its dollar sign ($) in the first column of the source line while the /4cc switch requires a character specifier as the first character of the source line.

To conditionally compile code involving metacommands, use the $DEFINE metacommand or the /D compiler option switch with the $IF, $ELSEIF, $ELSE, and $ENDIF metacomands. For more information, see pages 281-284 and page 335 of the Microsoft FORTRAN &quot;Reference&quot; manual for versions 5.0 and 5.1 or the FORTRAN PowerStation Language Help.



MORE INFORMATION
The following code example demonstrates conditionally compiling code that includes metacommands.

Sample Code
C Compile options needed: See below

$IF DEFINED(L) $INCLUDE 'large.inc' $ELSE $INCLUDE 'medium.inc' $ENDIF If the line &quot;$DEFINE L&quot; precedes this $IF block, the compiler includes the LARGE.INC file, otherwise the compiler includes the MEDIUM.INC file. This method provides the ability to hard code conditional changes.

To choose the version to compile from the command line, specify the /D compiler option switch to define the variable used in the $IF block. The /D option switch eliminates the need for the $DEFINE metacommand. In the previous example, to include the LARGE.INC file, use a compiler command line such as the following: fl /DL name.ext

Additional query words: kbinf 5.00 5.10 1.00 4.00

Keywords: kblangfortran KB49466

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.