我可能会疯了,但我不认为我曾经在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);
}