What's wrong with linux/ext2_fs.h?

落花浮王杯 提交于 2020-12-26 11:38:49

问题


cat main.c

#include <stdio.h>
#include <stdlib.h>
#include <linux/ext2_fs.h>

int main(int argc, char** argv) {

    return (EXIT_SUCCESS);
}

Here is my output...

gcc main.c In file included from main.c:3:

/usr/include/linux/ext2_fs.h: In function ‘ext2_mask_flags’:

/usr/include/linux/ext2_fs.h:182: error: ‘FS_DIRSYNC_FL’ undeclared (first use in this function)

/usr/include/linux/ext2_fs.h:182: error: (Each undeclared identifier is reported only once

/usr/include/linux/ext2_fs.h:182: error: for each function it appears in.)

/usr/include/linux/ext2_fs.h:182: error: ‘FS_TOPDIR_FL’ undeclared (first use in this function)

/usr/include/linux/ext2_fs.h:184: error: ‘FS_NODUMP_FL’ undeclared (first use in this function)

/usr/include/linux/ext2_fs.h:184: error: ‘FS_NOATIME_FL’ undeclared (first use in this function)

If I remove #include <linux/ext2_fs.h> the program compiles successfully...


回答1:


You need to add #include <linux/fs.h>




回答2:


You need to add #include <linux/fs.h> before including the #include <linux/ext2_fs.h>




回答3:


I had no idea, so I put ext2_fs.h into Google and this was the 4th result.

The behaviour seems to be considered a bug.




回答4:


I fixed it with:

#include <sys/stat.h>
#include <linux/fs.h>


来源:https://stackoverflow.com/questions/6969303/whats-wrong-with-linux-ext2-fs-h

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!