📄 fpp.1
字号:
block_1 \f3#elif \f2condition\f1 block_2 \f3#else\f1 block_n \f3#endif\f1.LPelse- and elif-part are optional. There may be more thanone elif-part. Condition is an expression involving .B fppconstants, macros and intrinsic functions. Condition expressions are similar to cpp expressions, and maycontain any cpp operations and operands with the exceptionof c long, octal and hexadecimal constants. Additionally,.B fpp will accept and evaluate Fortran logical operations .NOT. .AND.\&.OR. .EQV. .NEQV. .GT. .LT. .LE. .GE. etc. and logicalconstants .TRUE. .FALSE..SH Details.SS Scope of macro or variable definitions.The scope of a definition begins from the place of itsdefinition and encloses all the source lines (and source linesfrom included files) from that definition lineto the end of the current file. .LPThere are the following exceptions to the scope effected byan fpp definition:.LP- files included by Fortran INCLUDE statements;.LP- fpp and Fortran comments;.LP- IMPLICIT single letter specifications;.LP- FORMAT specifications;.LP- numeric, typeless and character constants..LPThe scope of the macro effect can be limited by meansof the #undef directive..SS End of macro definitionMacro definition can be of any length and is limitedonly by the 'newline' symbol. A Macro can be defined inmultiple lines. A Macro can be continued to the next linewith the insertion of '\e'. So, the occurrence of a 'newline'without a macro-continuation signifies the end of the macrodefinition..br.spFor example:.br#define long_macro_name(x,\e.bry) x*y.SS Function-like macro definitionThe number of macro call arguments should be the sameas the number of arguments in the corresponding macrodefinition. An error is flagged if they don't..SS Cancelling macro definitions of both kinds\f3#undef \f2name\f1.LPAfter this directive, 'name' would not interpreted by.B fppas a macro or variable name. If this name has not been definedearlier as a macro name, then the given directive hasno effect.SS Conditional source code selection.LP- Constant-expression.LPSubsequent lines up to the matching #else, #elif, or#endif directive, appear in the output only iftheir constant-expression yields a true value..LPThe lines following the #elif directive appear in the output only if all of the following conditionshold:.RS.TP-The constant-expression in the preceding#if directive evaluated to .FALSE..BI orthe name in the preceding #ifdef directiveis not defined.BI orthe name in the preceding #ifndef directiveis defined..TP-The constant-expression in all intervening #elif directives evaluated to .FALSE..TP-The current constant-expression evaluatesto .TRUE..RE.LPIf the constant-expression evaluates to .TRUE.,subsequent #elif and #else directives are ignoredup to the matching #endif. Any constant-expressionallowed in an #if directive is allowed in an #elifdirective..LPThe intrinsic function `defined' can be used in aconstant-expression also..LPThe following items are permitted:.RS.TP-C language operations: <, >, ==, !=, >=, <=, +, -, /, *, %, <<, >>,&, ~, |, &&, ||They are interpreted by.B fppin accordance to the C languagesemantics (this facility is provided for compatibility with"old" Fortran programs using cpp).TP-Fortran language operations: .AND., .OR., .NEQV., .XOR., .EQV., .NOT.\&, .GT., .LT., .LE., .GE., .NE., .EQ., ** (power)..TP-Fortran logical constants: .TRUE. , .FALSE..LPOnly these items, integer constants, and names can be used within a constant-expression. Nameswhich have not been defined with the help of the 'D' option, a #define directive or by default, get 0 as the value.The C operation '!=' (not equal) can be used in #if or#elif directive, but NOT in #define directive, wherethe symbol '!' is considered as the Fortran comment symbol..RE.TP.BI #ifdef " name "Subsequent lines up to the matching #else, #elif,or #endif appear in the output only if the name has been defined, either by a #define directive or by the 'D' option, and in the absence of an intervening #undefdirective. No additional tokens are permitted on thedirective line after name..TP.BI #ifndef " name "Subsequent lines up to the matching #else, #elif,or #endif appear in the output only if name has not been defined, or if its definition has been removedwith an #undef directive. No additional tokens arepermitted on the directive line after name..TP.BI #elif " constant-expression ".Any number of #elif directives may appear betweenan #if, #ifdef, or #ifndef directive and a matching#else or #endif directive..TP.BI #elseThis inverts the sense of the conditional directive otherwise in effect. If the preceding conditional wouldindicate that lines are to be included, then lines between the #else and the matching #endif are ignored.If the preceding conditional indicates that lines wouldbe ignored, subsequent lines are included in theoutput..BRConditional directives and corresponding #else directives can be nested..TP.BI #endifEnd a section of lines begun by one of the conditional directives #if, #ifdef, or #ifndef.Each such directive must have a matching #endif..SS Including External Files Is the same as it is for cpp.Files are searched as follows:.LPfor #include "file_name":.RS.TP-in the directory, in which the processed file has been found;.TP-in the directories specified by the -I option;.TP-in the default directory..RE.LPfor #include <file_name>:.RS.TP-in the directories specified by the -I option;.TP-in the default directory..RE.LP.B fppdirectives (beginning with the # symbol in the firstposition of lines) can be placed anywhere in a source code,in particular before a Fortran continuation line.The only exception is the prohibition of .B fppdirectiveswithin a macro call divided on several lines by meansof continuation symbols..LP.SS Comments.LP.B fpp permits comments of two kinds:.LP1) Fortran language comments.A source line containing one of the symbols 'C', 'c', '*', 'd' or 'D' in the first position,is considered as a comment line. Within such linesmacro expansions are not performed.The '!' symbol is interpreted as the beginning of acomment extending to the end of the line. The only exceptionis the case when this symbol occurs within aconstant-expression in #if and #elif directives(See above). .LP2) .B fpp comments enclosed in the '/*' and '*/' parasymbols.They are excluded from the output and macro expansions are not performed within these symbols. .B fppcomments can be nested and for each parasymbol '/*'there must be a corresponding parasymbol '*/'..B fpp comments are suitable for excluding the compilation oflarge portions of source instead of commenting every linewith Fortran comment symbols..LP.SS Intrinsic functions.LPThe intrinsic function.LP\f3defined(\f2name\f3)\f1 or \f3defined \f2name\f3 \f1.LPReturns:.LP .TRUE. - if name is defined as a macro..LP .FALSE.- if the name is not defined..LP.SS Macro expansion.LPIf, during expansion of a macro, the column width of aline exceeds column 72 (for the fixed format) or column 132(for the free format),.B fpp inserts appropriate continuationlines..LPIn the fixed form there is limitation on macro expansionsin label fields (positions 1-5):.RS.TP-a macro call (together with possible arguments) should notextend more than the column 5 position;.TP-a macro call whose name begins with one of the Fortrancomment symbols is considered as a part of a comment;.TP-a macro expansion may produce a text extending beyond thecolumn 5 position. In such a case a warning will be issued..RE.LPIn the fixed form when the '-Xw' option has been specifiedan ambiguity may appear if a macro call occurs in a statementposition and a macro name begins or coincides with a Fortrankeyword. For example, in the following text:.LP #define callp(x) call f(x) call p(0) .LP.B fpp can not determine with certainty how to interpret the 'call p'token sequence. It could be considered as a macro name. The current implementation does the following:.RS.TP-the longer identifier is chosen (callp in this case);.TP-from this identifier the longest macro name or keywordis extracted;.TP-if a macro name has been extracted a macro expansion isperformed. If the name begins with some keyword.B fppoutputs an appropriate warning;.TP-the rest of the identifier is considered as a wholeidentifier..RE.LPIn the above example the macro expansion would be performedand the following warning would be output:.LPwarning: possibly incorrect substitution of macro callp.LPIt should be noted that this situation appears only whenpreprocessing a fixed format source code and when thespace symbol is not interpreted as a token delimiter.It should be said also that if a macro name coincideswith a keyword beginning part, as in the following case:.LP #define INT INTEGER*8 INTEGER k.LPthen in accordance with the described algorithm, theINTEGER keyword will be found earlier than the INTmacro name. Thus, there will be no warning whenpreprocessing such a macro definition. .SH DIAGNOSTICS .LPThere are three kinds of diagnostic messages:.RS.TP-warnings.preprocessing of source code is continued andthe return value remains to be 0..TP-errors..B fpp continues preprocessing but sets the returncode to a nonzero value, namely number of errors. .TP-fatal error..B fpp cancels preprocessing and returns a nonzeroreturn value. .RE.LP The messages produced by.B fpp are intended to be self-explanatory. The line number and filename where the erroroccurred are printed along with the diagnostic..SH SEE ALSO.LPcpp(1), f77(1), f90(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -