C 如何解决这种语义错误?
我正在使用带有Eclipse IDE的Linux操作系统。添加C 如何解决这种语义错误?,c,linux,eclipse,gcc,compiler-construction,C,Linux,Eclipse,Gcc,Compiler Construction,我正在使用带有Eclipse IDE的Linux操作系统。添加#在开始时包括。您需要两件小事 如上所述,#包括 计时器\u创建需要 关于(2),当您查看time\u create的手册页时,在大纲区域中,它将告诉您哪些功能需要特定的宏 因此,快速解决方案是将以下内容定义为上述代码的第一行,然后在其后某处添加time.h标题 Invoking: GCC C Compiler gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/new.d
#在开始时包括。您需要两件小事
如上所述,#包括
计时器\u创建
需要
关于(2),当您查看time\u create
的手册页时,在大纲区域中,它将告诉您哪些功能需要特定的宏
因此,快速解决方案是将以下内容定义为上述代码的第一行,然后在其后某处添加time.h
标题
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/new.d" -MT"src/new.d" -o "src/new.o" In 'CLOCK_REALTIME' undeclared (first use in this function)
Field 'tv_nsec' could not be resolved Semantic Error
Field 'tv_nsec' could not be resolved Semantic Error
Field 'tv_sec' could not be resolved Semantic Error
Field 'tv_sec' could not be resolved Semantic Error
storage size of 'itime' isn't known C/C++ Problem
较长的解决方案是阅读feature\u test\u宏
手册页,因为您将一直遇到这种情况
顺便说一句,请确保您再次链接到librt
,即-lrt
您阅读了吗?您缺少手册页中特别提到的头文件。有人回答为:成功地使用-std=gnu99运行??哪里有那个??把它作为gcc
中的一个论据添加。我按照你说的做了,但这对你的回答不起作用。如何以及在哪里链接-lrt??我不知道Eclipse如何处理它,但您需要将librt添加到链接库中。我确信在某个地方有一个菜单项可以做到这一点。最终的结果是编译命令看起来像是gcc-g-Wall-ofoo-foo.c-lrt
,等等。
Invoking: GCC C Compiler
gcc -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/new.d" -MT"src/new.d" -o "src/new.o" In 'CLOCK_REALTIME' undeclared (first use in this function)
Field 'tv_nsec' could not be resolved Semantic Error
Field 'tv_nsec' could not be resolved Semantic Error
Field 'tv_sec' could not be resolved Semantic Error
Field 'tv_sec' could not be resolved Semantic Error
storage size of 'itime' isn't known C/C++ Problem
#define _POSIX_C_SOURCE 199309L