ヘッダーファイルを調べてきましたが、ステータスフラグが定義されているファイル(O_RDONLYなど)が見つかりません。
ありがとう、ジョン
概要
Linux を使用している場合は、/usr/include/bits/fcntl.h
.
#define O_RDONLY 00
、 または 、または、rgrep
またはctags
を使用して見つけることができます。Vim
cpp
cwhere
rgrep
最も簡単な方法はrgrep
、別名を使用することgrep -R
です。
$ rgrep O_WRONLY .
./X11/Xw32defs.h:# define O_WRONLY _O_WRONLY
./linux/fs.h: * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
./linux/smbno.h:#define SMB_O_WRONLY 0x0001
./asm-generic/fcntl.h:#define O_WRONLY 00000001
./security/_pam_macros.h: if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_NOFOLLOW|O_APPEND)) != -1) {
./security/_pam_macros.h: if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_APPEND)) != -1) {
./security/_pam_macros.h: if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_NOFOLLOW|O_APPEND)) != -1) {
./security/_pam_macros.h: if ((fd = open(_PAM_LOGFILE, O_WRONLY|O_APPEND)) != -1) {
./bits/fcntl.h:#define O_WRONLY 01
ctags
ctags -R
または、実行し/usr/include
てから実行することもできますvim -t O_WRONLY
。
または、もう少し良いですが、より多くのタイピング:
find . /usr/include -name "*.h" |
ctags -f - -L - |
grep "^O_WRONLY " |
cut -d " " -f 1,2,3 |
sed -e 's# /\^# #;s#\$/\;"$##'
cpp
私が見つけた最良の方法は、を使用することcpp
です。
#include
必要なsを含む YOUR_SOURCE_FILE というソース ファイルがあると仮定して、次のコマンドを実行してみてください。
cpp -dD YOUR_SOURCE_FILE | less
次に#define
、たとえばを検索し/O_WRONLY
、上にスクロールして、その上にある最初のファイル名を見つけます。この場合:
# 27 "/usr/include/bits/fcntl.h" 2 3 4
に記載されている 3 つのヘッダー ファイルをインクルードすると、O_WRONLY
がピックアップされていることを意味します。/usr/include/bits/fcntl.h
man fcntl
どこで
cwhere
実行を自動化するために呼び出されるスクリプトがありますcpp
:
$ cwhere O_WRONLY sys/types.h sys/stat.h fcntl.h
/usr/include/bits/fcntl.h: #define O_WRONLY 01
がインストールされている場合は、desc
それを使用する関数の名前を入力できます。#define
$ cwhere O_WRONLY 'fcntl()'
/usr/include/bits/fcntl.h: #define O_WRONLY 01