c - 编译v4l2程序时ioport.h错误

标签 c header v4l2 v4l ioports

我想关注这个article关于v4l2的驱动编写。

但是当我包含 media/v4l2-dev.h 时,我的第一次基本尝试失败了(因为我想访问一些宏,例如 VFL_TYPE_GRABBER)。

media/v4l2-dev.h 包含 linux/device.h,其中包含 linux/ioport.h,它会因以下输出而崩溃:

In file included from /usr/src/linux/include/linux/device.h:16,
                 from /usr/src/linux/include/media/v4l2-dev.h:14,
                 from driv.c:11:
/usr/src/linux/include/linux/ioport.h:19: error: expected specifier-qualifier-list         before ‘resource_size_t’
/usr/src/linux/include/linux/ioport.h:116: error: expected declaration specifiers or ‘...’ before ‘resource_size_t’
/usr/src/linux/include/linux/ioport.h:116: error: expected declaration specifiers or ‘...’ before ‘resource_size_t’
/usr/src/linux/include/linux/ioport.h:121: error: expected declaration specifiers or ‘...’ before ‘resource_size_t’

[...]

来源:

#include <asm/types.h>
#include <linux/videodev2.h>

#include <media/v4l2-dev.h>

int main(int argc, char **argv) {
    return 0;
}

我编译的是:

gcc -I/usr/src/linux/arch/x86/include -I/usr/src/linux/include -o prog prog.c

它出现在 2.6.32-37-generic-pae 上,使用 gcc 4.4.3 glibc 2.10 我在 gentoo 上尝试了同样的操作,内核头文件和 gcc 的版本大致相同。

我做错了什么?

编辑:指示确切的包含路径。

最佳答案

如果您正在进行驱动程序开发,您不妨使用提供的框架来这样做。 我建议从现有的驱动程序构建项目(例如 that 一个)开始,通常是一个像这样简单的 Makefile:

KERNEL_VERSION := `uname -r`
KERNEL_DIR := /lib/modules/$(KERNEL_VERSION)/build

PWD := $(shell pwd)

obj-m := mymodule.o

all: mymodule
mymodule:
    @echo "Building my driver..."
    $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules
install:
    $(MAKE) -C $(KERNEL_DIR) M=$(PWD) modules_install
    depmod -ae
clean:
    rm -f *~
    rm -f Module.symvers Module.markers modules.order
    $(MAKE) -C $(KERNEL_DIR) M=$(PWD) clean

而不是尝试事后猜测哪些路径包含您需要的路径。

此外,您可能不应该在需要头文件之前包含它们。

关于c - 编译v4l2程序时ioport.h错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10703662/

相关文章:

c - 当 char* x 指向一个值等于 "hello"的字符串时,如何在 gdb 中设置条件断点?

c - 图像大小调整程序输出扭曲的图像

html - 为什么这段内容会出现在header标签内容下面?

python - cv2.videocapture.read() 不返回 numpy 数组

ffmpeg 水平翻转网络摄像头到虚拟摄像机

c++ - 在没有 MSVCRT 运行时的情况下在 Visual Studio 2012 中编译 C

C 可以作为混合语言实现吗?

c# - 将自定义 header 添加到 excel 文件

WPF 工具包数据网格 : how to get ColumnHeader width to be the same as GridColumn width

c++ - 如何并行化这个 for 循环以快速将 YUV422 转换为 RGB888?