Warning: ××× ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated (declared at /usr/include/dirent.h:183) [-Wdeprecated-declarations] ×××
具体警告提示:
/mnt/Data/AppsData/Repository/java/jdk/8/hotspot/src/os/linux/vm/os_linux.inline.hpp: In static member function ‘static dirent* os::readdir(DIR*, dirent*)’:
/mnt/Data/AppsData/Repository/java/jdk/8/hotspot/src/os/linux/vm/os_linux.inline.hpp:127:18: warning: ‘int readdir_r(DIR*, dirent*, dirent**)’ is deprecated (declared at /usr/include/dirent.h:183) [-Wdeprecated-declarations]
if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
^
分析原因:
1. gcc 编译环境中开启了相关警告提示
解决方案:
1. 查看./hotspot/make/[you_os]/makefiles/gcc.make
文件
在./hotspot/make/linux/makefiles/gcc.make
文件中找到
WARNINGS_ARE_ERRORS = -Werror
将其 注释 或改为
WARNINGS_ARE_ERRORS = -Wno-all
类似的警告都可以通过以下参数来设置,在该文件下找到WARNING_FLAGS
,就在上述变量附近,添加需要注释的警告
WARNING_FLAGS = -Wno-deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-error
或者关闭所有警告
WARNING_FLAGS = -w
不过貌似只对编译hotspot时有用