0

I am reading the source code of GCC 3.1 recently, and I have found some weird function declarations.

For example:

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;
}

I guess the declaration is equivalent to

struct c_fileinfo *get_fileinfo (const char* name)

right?

And why does the code need to be written this way?

Thank you in advance!

Jiahao Cai
  • 1,222
  • 1
  • 11
  • 25
  • "And why does the code need to be written this way?" - **You should never write a function definition like that! It is a legacy and obsolecent, i.e. it is to be removed from the standard.** Just forget this ever existed! Use modern C and a good textbook which covers at least C99, better standard C, i.e. C11 to learn the language. – too honest for this site Apr 08 '17 at 04:07
  • OK, I am just being curious, thank you for your explanation.@Olaf – Jiahao Cai Apr 08 '17 at 04:09

0 Answers0