open函数中O_CLOEXEC标志的开关
????? 雖然新版本支持在open時(shí)設(shè)置CLOEXEC,但是在編譯的時(shí)候還是會(huì)提示錯(cuò)誤 - error: ‘O_CLOEXEC’ undeclared (first use in this function)。原來這個(gè)新功能要求我們手動(dòng)去打開,需要設(shè)置一個(gè)宏(_GNU_SOURCE)??赏ㄟ^以下兩種方法來設(shè)置這個(gè)宏以打開新功能:
1. 在源代碼中加入 #define _GNU_SOURCE
2. 在編譯參數(shù)中加入 -D_GNU_SOURCE
?
gcc 還有很多其他的開關(guān),具體可以參考
--------------------------- /usr/include/features.h -----------------------------------------------
These are defined by the user (or the compiler) to specify the desired environment:
?? __STRICT_ANSI__????? ISO Standard C.
?? _ISOC99_SOURCE?????? Extensions to ISO C89 from ISO C99.
?? _POSIX_SOURCE??????? IEEE Std 1003.1.
?? _POSIX_C_SOURCE????? If ==1, like _POSIX_SOURCE; if >=2 add IEEE Std 1003.2;
??????????????????????? if >=199309L, add IEEE Std 1003.1b-1993;
??????????????????????? if >=199506L, add IEEE Std 1003.1c-1995;
??????????????????????? if >=200112L, all of IEEE 1003.1-2004
?? _XOPEN_SOURCE??????? Includes POSIX and XPG things.? Set to 500 if
??????????????????????? Single Unix conformance is wanted, to 600 for the
??????????????????????? upcoming sixth revision.
?? _XOPEN_SOURCE_EXTENDED XPG things and X/Open Unix extensions.
?? _LARGEFILE_SOURCE??? Some more functions for correct standard I/O.
?? _LARGEFILE64_SOURCE? Additional functionality from LFS for large files.
?? _FILE_OFFSET_BITS=N? Select default filesystem interface.
?? _BSD_SOURCE????????? ISO C, POSIX, and 4.3BSD things.
?? _SVID_SOURCE???????? ISO C, POSIX, and SVID things.
?? _ATFILE_SOURCE?????? Additional *at interfaces.
?? _GNU_SOURCE????????? All of the above, plus GNU extensions.
?? _REENTRANT?????????? Select additionally reentrant object.
?? _THREAD_SAFE???????? Same as _REENTRANT, often used by other systems.
?? _FORTIFY_SOURCE????? If set to numeric value > 0 additional security
??????????????????????? measures are defined, according to level.
?
------------------------------------------------------------------------------------------
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的open函数中O_CLOEXEC标志的开关的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 南方零钱佳和易方达余额佳的区别,体现在这
- 下一篇: 详细介绍Qt,ffmpeg 和SDl 教