C中不寻常的函数声明

时间:2017-04-08 02:23:18

标签: c function gcc

我最近正在阅读GCC 3.1的源代码,我发现了一些奇怪的函数声明。

例如:

struct c_fileinfo *
get_fileinfo (name)
     const char *name;
{
  splay_tree_node n;
  struct c_fileinfo *fi;

  n = splay_tree_lookup (file_info_tree, (splay_tree_key) name);
  if (n)
    return (struct c_fileinfo *) n->value;

  fi = (struct c_fileinfo *) xmalloc (sizeof (struct c_fileinfo));
  fi->time = 0;
  fi->interface_only = 0;
  fi->interface_unknown = 1;
  splay_tree_insert (file_info_tree, (splay_tree_key) name,
             (splay_tree_value) fi);
  return fi;
}

我猜这个声明等同于

struct c_fileinfo *get_fileinfo (const char* name)

正确?

为什么代码需要以这种方式编写?

提前谢谢!

0 个答案:

没有答案