在git的源代码中,我看到了以下函数定义。
我认为在这里
这意味着什么,如何使用这个
源代码链接: https://github.com/git/git/blob/7d722536dd86b5fbd0c0434bfcea5588132ee6ad/object.c#L29
const char *typename(unsigned int type)
{
if (type >= ARRAY_SIZE(object_type_strings))
return NULL;
return object_type_strings[type];
}
我认为在这里
typename
是一个函数,但它似乎是一个const
函数,这让我很困惑。这意味着什么,如何使用这个
const
函数特性?源代码链接: https://github.com/git/git/blob/7d722536dd86b5fbd0c0434bfcea5588132ee6ad/object.c#L29
const char *
的函数。(除了函数的属性static
之外,“const”在这里修饰了返回类型。) - M Oehmconst char *
的函数。 - Paul R