简体   繁体   中英

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. 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:

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.

I appreciate you advice :)

In C language, you must declare variables at the start of a C block {}. You cannot have declarations interleaved between instructions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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