求教大神int unlink( nm ) STRING nm; {}这句语法怎么理解
背景介绍:
这句话出至SL-qc88.c文件,这个文件在PClint里,PClint是一个非常严格的C/C++编译器, 可以嵌入到VC.GCC等.它甚至能够检查出你C/C++代码中的内层泄漏问题,变量未初始化问题,不安全的使用指针等...微软公司把它作为代码检查工具,只有通过它才能正式发行
我发现使用的时候直接使用就可以unlink(FILE_NAME_TMP);
问题:
int unlink( nm ) STRING nm; {}中
1.nm不需要表明变量类型么?
2.STRING nm;在这里是定义nm么?
3.后面的括号是什么意思?
4.这句话的作用是什么?
小弟才疏学浅,望前辈指点
语法解析
[解决办法]
C里面 老式的函数写法
nm是参数 STRING nm;指明参数nm为STRING类型 {}是函数体
[解决办法]
C Function Definitions
A function definition specifies the name of the function, the types and number of parameters it expects to receive, and its return type. A function definition also includes a function body with the declarations of its local variables, and the statements that determine what the function does.
Syntax
translation-unit :
external-declaration
translation-unit external-declaration
external-declaration : /* Allowed only at external (file) scope */
function-definition
declaration
function-definition : /* Declarator here is the function declarator */
declaration-specifiersopt attribute-seqopt declarator declaration-listopt compound-statement
/* attribute-seq is Microsoft Specific */
Prototype parameters are:
declaration-specifiers :
storage-class-specifier declaration-specifiers opt
type-specifier declaration-specifiers opt
type-qualifier declaration-specifiers opt
declaration-list :
declaration
declaration-list declaration
declarator :
pointeropt direct-declarator
direct-declarator : /* A function declarator */
direct-declarator ( parameter-type-list ) /* New-style declarator */
direct-declarator ( identifier-list opt ) /* Obsolete-style declarator */
The parameter list in a definition uses this syntax:
parameter-type-list : /* The parameter list */
parameter-list
parameter-list , ...
parameter-list :
parameter-declaration
parameter-list , parameter-declaration
parameter-declaration :
declaration-specifiers declarator
declaration-specifiers abstract-declarator opt
The parameter list in an old-style function definition uses this syntax:
identifier-list : /* Used in obsolete-style function definitions and declarations */
identifier
identifier-list , identifier
The syntax for the function body is:
compound-statement : /* The function body */
{ declaration-list opt statement-list opt }
The only storage-class specifiers that can modify a function declaration are extern and static. The extern specifier signifies that the function can be referenced from other files; that is, the function name is exported to the linker. The static specifier signifies that the function cannot be referenced from other files; that is, the name is not exported by the linker. If no storage class appears in a function definition, extern is assumed. In any case, the function is always visible from the definition point to the end of the file.
The optional declaration-specifiers and mandatory declarator together specify the function’s return type and name. The declarator is a combination of the identifier that names the function and the parentheses following the function name. The optional attribute-seq nonterminal is a Microsoft-specific feature defined in Function Attributes.
The direct-declarator (in the declarator syntax) specifies the name of the function being defined and the identifiers of its parameters. If the direct-declarator includes a parameter-type-list, the list specifies the types of all the parameters. Such a declarator also serves as a function prototype for later calls to the function.
A declaration in the declaration-list in function definitions cannot contain a storage-class-specifier other than register. The type-specifier in the declaration-specifiers syntax can be omitted only if the register storage class is specified for a value of int type.
The compound-statement is the function body containing local variable declarations, references to externally declared items, and statements.
The sections Function Attributes, Storage Class, Return Type, Parameters, and Function Body describe the components of the function definition in detail.
[解决办法]