Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 timeval 结构来获取当前系统时间。通常,如果我这样声明:
timeval curtime;
这是工作。但是我看到了一些人们将其声明为的代码:
struct timeval curtime;
这两者有什么区别吗?
struct在 C 中,声明结构类型的变量时必须使用前缀。
struct
在 C++ 中,不需要前缀struct.
由于您已将此标记为 C++ 问题,因此我假设您使用的是 C++ 编译器,因此在不使用前缀timeval的情况下使用时不会出现编译器错误。struct但是,如果您要使用 C 编译器,则会发出错误。
timeval