简体   繁体   English

英特尔C编译器无法在Linux上使用标准库(例如dirent.h)

[英]Intel C Compiler unable to use standard libs (e.g. dirent.h) on Linux

I am having an issue with the Intel C Compiler icc , which refuses to recognize some standard libraries such as dirent.h. 我遇到了Intel C Compiler icc ,该问题拒绝识别某些标准库,例如dirent.h。 My code looks like this: 我的代码如下所示:

#include <dirent.h>
...
DIR* dir = opendir(path);
...
readdir(dir);
dirent* entry = readdir(dir);
while(entry != NULL) {
    ...
    entry = readdir(dir);
}

Upon trying to compile the code, I get the following error, even if I explicitly add -I/usr/include to the command: 尝试编译代码时,即使我将-I/usr/include显式添加到命令中,我也会遇到以下错误:

icc -g -ipp=common -mkl=parallel -I/opt/intel/ipp/include -I"../include" -std=c99 -openmp -cilk-serialize -fpic -MMD -MP -MF"src/main.d" -MT"src/main.d" -c -o "src/main.o" "../src/main.c"
../src/main.c(85): error: identifier "dirent" is undefined
dirent* entry = readdir(dir);

GCC compiles the same code withough any problem - unfortunately, I need to compile my application with ICC for other reasons. GCC可以毫无问题地编译相同的代码-不幸的是,由于其他原因,我需要使用ICC编译我的应用程序。

I appreciate you advice :) 我感谢您的建议:)

In C language, you must declare variables at the start of a C block {}. 在C语言中,必须在C块{}的开头声明变量。 You cannot have declarations interleaved between instructions. 您不能在指令之间插入声明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM