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

标签 c linux icc

我在使用英特尔 C 编译器 icc 时遇到问题,它拒绝识别某些标准库,例如 dirent.h。我的代码如下所示:

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

在尝试编译代码时,我收到以下错误,即使我明确地将 -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 编译相同的代码没有任何问题 - 不幸的是,由于其他原因我需要使用 ICC 编译我的应用程序。

感谢您的建议:)

最佳答案

在 C 语言中,您必须在 C block {} 的开头声明变量。您不能在指令之间交错声明。

关于c - 英特尔 C 编译器无法在 Linux 上使用标准库(例如 dirent.h),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20327553/

相关文章:

linux - 当我将编译器从 GCC 3.4.2 切换到 GCC 4.4.2 或 ICC 时需要注意什么?

php - 一起使用 c++ 和 php

c++ - 使用 `bdrv_pread(..)` 或替代品读取 qcow2 图像的内容

c++ - 让系统调用 `select()` 阻塞,直到套接字获得可读取的内容

linux - 如何在 linux date 命令中获取 Date Month 值作为整数来处理

c - lcms2 通过 C 中的配置文件将 CMYK 转换为 RGB - 关于输入/输出值的帮助

c - 无限循环和结构

php - Laravel 5.1 服务器 - 找不到类

linux - 使用 Linux 删除前 6 列

c++ - gcc 和 intel 在 redhat 上的 icpc 不识别命名空间 std::literals;