[英]static size_t strnlen(const char *s, size_t max) — why a static return value?
我可能会疯了,但我不认为我曾经在c ++中看到过这种情况(尽管我的参考代码是在C中)。 为什么这里代码的返回值有静态,它有什么影响? 我不认为我曾经见过类范围之外的静态函数(但显然C没有类,这可能有不同的语法含义)。
/* just like strlen(3), but cap the number of bytes we count */
static size_t strnlen(const char *s, size_t max) {
register const char *p;
for(p = s; *p && max--; ++p);
return(p - s);
}
static不在返回类型上,而是在函数定义上 。
静态函数基本上没有外部链接它们只对同一文件中的其他函数可见。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.