天天看點

error: call to '__creat_missing_mode' declared with attribute error

int fd;

fd=open("/data/data/tmp.txt", O_WRONLY|O_CREAT);

write(fd, prop_name, sizeof(prop_name));

close(fd);

ERROR:

In file included from hardware/libhardware/hardware.c:29:0:

In function 'open',

    inlined from 'hw_get_module_by_class' at hardware/libhardware/hardware.c:175:3:

bionic/libc/include/fcntl.h:100:13: error: call to '__creat_missing_mode' declared with attribute error: called with O_CREAT, but missing mode

             __creat_missing_mode();  // compile time error

SOLUTION:

fd=open("/data/data/tmp.txt", O_WRONLY|O_CREAT,

0666);

使用open函數時,如果在第二個參數中使用了 O_CREAT,就必須添加第三個參數:建立檔案時賦予的初始權限。

繼續閱讀