From: Tanaka Akira Date: 2003-10-08T12:42:19+09:00 Subject: [ruby-dev:21546] Re: O_ACCMODE In article <20031008064542.CC54.ZN@mbf.nifty.com>, Kazuhiro NISHIYAMA writes: > 上では > > #ifdef O_RDONLY > rb_define_const(mFcntl, "O_RDONLY", INT2NUM(O_RDONLY)); > #endif > > のようにifdefでチェックしてINT2NUMなのにO_ACCMODEのところでは > チェックなしでINT2FIXで大丈夫なのかという心配をしなくてすみます。 io.c で rb_file_const("RDONLY", INT2FIX(O_RDONLY)); というようにしているので、ruby はそれでも大丈夫な状況を仮定しているの ではないでしょうか。 とりあえず /usr/include から O_RDONLY の定義を取り除いて、#ifdef のほ うを試してみると、 % make gcc -g -O2 -I. -I. -c array.c gcc -g -O2 -I. -I. -c bignum.c gcc -g -O2 -I. -I. -c class.c gcc -g -O2 -I. -I. -c compar.c gcc -g -O2 -I. -I. -c dir.c gcc -g -O2 -I. -I. -c dln.c gcc -g -O2 -I. -I. -c enum.c gcc -g -O2 -I. -I. -c error.c gcc -g -O2 -I. -I. -c eval.c gcc -g -O2 -I. -I. -c file.c gcc -g -O2 -I. -I. -c gc.c gcc -g -O2 -I. -I. -c hash.c gcc -g -O2 -I. -I. -c inits.c gcc -g -O2 -I. -I. -c io.c io.c: In function `rb_io_modenum_flags': io.c:1707: `O_RDONLY' undeclared (first use in this function) io.c:1707: (Each undeclared identifier is reported only once io.c:1707: for each function it appears in.) io.c:1709: warning: unreachable code at beginning of switch statement io.c: In function `rb_io_mode_modenum': io.c:1737: `O_RDONLY' undeclared (first use in this function) io.c: In function `rb_io_modenum_mode': io.c:1775: `O_RDONLY' undeclared (first use in this function) io.c:1777: warning: unreachable code at beginning of switch statement io.c: In function `rb_io_s_sysopen': io.c:2287: `O_RDONLY' undeclared (first use in this function) io.c: In function `rb_io_s_pipe': io.c:3613: `O_RDONLY' undeclared (first use in this function) io.c: In function `Init_IO': io.c:4199: `O_RDONLY' undeclared (first use in this function) make: *** [io.o] Error 1 というように、fcntl.c にたどり着きませんでした。 -- [田中 哲][たなか あきら][Tanaka Akira]