我一直对这里发生的事情感到有些困惑:
#include <stdio.h>
int main() {
timeval tv;
tv.tv_sec = 1;
for (;;) {
select(0, 0, 0, 0, &tv);
printf("%s\n", "Hello World!");
}
}
Run Code Online (Sandbox Code Playgroud)
很抱歉,如果没有编译,只需将其作为一个简单的例子写下来.
像这样的代码不会在gcc下编译,除非我在使用struct timeval之前添加关键字struct.另一方面,g ++处理得很好.
这是C和C++如何处理结构之间的区别,还是只是编译器的差异?(我非常注重C++,在像这样的C行中使用struct总是让我感到困惑).