-qgenproto(仅限 C)

适用的调用

表 1. 接受给定选项的调用
选项 xlc (编译 C) xlC (编译 C++) xlclang(编译 C) xlclang++(编译 C++)
-qgenproto      
注: 此表中仅列出典型调用。 对于所有基本调用及其等效特殊调用,您可以参阅 编译器调用的完整列表

类别

可移植性和迁移

等效编译指示

无。

用途

通过 K&R 函数定义或者含空括号的函数定义来生成原型声明,并将其显示在标准输出中。

The compiler accepts and compiles K&R function definitions or definitions with a function declarator with empty parentheses; however, these function definitions are considered by the C standard to be obsolete (the compiler will diagnose them if you enable the -qinfo=obs option). 当 -qgenproto 生效时,编译器将生成相应的原型声明并将它们显示到标准输出中。 您可以使用此选项来帮助您识别过时的函数定义并自动获取等效原型。

语法

读取语法图跳过可视语法图 -q nogenprotogenproto=parmnames

缺省值

-qnogenproto

参数

参数名
参数名称包含在原型中。 如果未指定此子选项,那么参数名称将不会包含在原型中。

预定义的宏

无。

示例

使用 - qgenproto 针对以下函数定义进行编译:
int foo(a, b)   // K&R function
  int a, b;
{
}

int faa(int i) { } // prototyped function

main() {  // missing void parameter 
}
在屏幕上生成以下输出:
int foo(int, int);
int main(void);
指定 -qgenproto=parmnames 将生成:
int foo(int a, int b);
int main(void);