使用open
函数的时候,如果在第二个参数中使用了O_CREAT
,就必须添加第三个参数:创建文件时赋予的初始权。
1 2 3 4 5 6 |
In function ‘open’, inlined from ‘test_detector_ffmpeg’ at ./src/ff_darknet.c:421:15: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments __open_missing_mode (); ^ compilation terminated due to -Wfatal-errors. |
建议使用如下参数创建文件:
1 2 |
//0755 fd = open(file_path,O_CREAT | O_APPEND | O_WRONLY,S_IRWXU|S_IRUSR|S_IXUSR|S_IROTH|S_IXOTH); |