因为你没有显式地用struct stat而是直接用stat来定义结构体吧,毕竟stat函数和结构体都是一个名字。
参考下面代码,编译会报错

$ cat a.cpp 
#include <stdio.h>

struct foo {
    int i = 1;
};

void foo(struct foo& x) { printf("%d\n", x.i); }

int main() {
    foo x;
    foo(x);
    return 0;
}
$ g++ a.cpp -std=c++11
a.cpp: In function ‘int main()’:
a.cpp:10:9: error: expected ‘;’ before ‘x’
     foo x;
         ^
a.cpp:11:9: error: ‘x’ was not declared in this scope
     foo(x);