p; 当 calls 打印出调用跟踪结果时, 它在函数后面用中括号给出了函数所在文件的文件名:main [test.c] 如果函数并不是向 calls 给出的文件里的, calls 不知道所调用的函数来自哪里, 则只显示函数的名字:printf calls 不对递归和静态函数输出. 递归函数显示成下面的样子:fact <<< recursive in factorial.c >>> 静态函数象这样显示:total [static in calculate.c] 作为一个例子, 假设用 calls 处理下面的程序: #include <stdio.h>
main ()
{
char my_string[] = "hello there";
my_print (my_string);
my_print2(my_string);
}
my_print (char *string)
{
printf ("The string is %s\n", string);
}
my_print2 (char *string)
{
char *string2;
int size, size2, i;
size = strlen (string);
size2 = size -1;
string2 = (char *) malloc (size + 1);
for (i = 0; i < size; i++)
string2[size2 - i] = string[i];
string2[size] = `\0';
printf ("The string printed backward is %s\n", string2);
} 将产生如下的输出: 1 main [test.c]
2 my_print [test.c]
3 printf
4 my_print2 [test.c]
5 strlen
6 malloc
7 printfcalls 有很多命令行选项来设置不同的输出格式, 有关这些选项的更多信息请参考 calls 的指南页. 方法是在命令行上键入 calls -h . cproto cproto 读入 C 源程序文件并自动为每个函数产生原型申明. 用 cproto 可以在写程序时为你节省大量用来定义函数原型的时间. 如果你让 cproto 处理下面的代码:#include <stdio.h>
main ()
{
char my_string[] = "hello there";
my_print (my_string);
my_print2(my_string);
}
my_print (char *string)
{
printf ("The string is %s\n", *string);
}
my_print2 (char *string)
{
char *string2;
int size, size2, i;
size = strlen (string);
size2 = size -1;
string2 = (char *) malloc (size + 1);
for (i = 0; i < size; i++)
string2[size2 - i] = string[i];
string2[size] = `\0';
printf ("The string printed backward is %s\n", string2);
} 你将得到下面的输出:/* test.c */
int main(void);
int my_print(char *string);
int my_print2(char *string); 这个输出可以重定向到一个定义函数原型的包含文件里.indent indent 实用程序是 Linux 里包含的另一个编程(www.cppentry.com)实用工具. 这个工具简单的说就为你的代码产生美观的缩进的格式. indent 也有很多选项来指定如何格式化你的源代码.这些选项的更多信息请看indent 的指南页, 在命令行上键入 indent -h . 下面的例子是 indent 的缺省输出: 运行 indent 以前的 C 代码:#include <stdio.h>
main () {
char my_string[] = "hello there |