FreeBSD QandA 705
Q. FreeBSD の kernel の source file を見ていて、次のような記述を見掛け
ました。
#endif NETATALK
#endif の後に、コメントがあるのは良く見ますが、このような記述もあるの
でしょうか?
A. 昔使われていた記述方法です。
info で、cpp -> conditionals -> Conditional Syntax -> #if Directive
とたどっていくと、次のような説明があります。
In fact, you can put anything at all after the `#endif'
and it will be ignored by the GNU C preprocessor,
but only comments are acceptable in ANSI Standard C.
FreeBSD で使われる cc は、GNU C compiler ですので、このような記述がさ
れていても無視されるようです。
GNU C compiler で、option に -ansi -pedantic を付けて compile すると、
ANSI Standard C として動作し warning が出されます。
実際に、option に -ansi -pedantic を付けて compile すると、次のように
warning が出ました。(gcc version 2.7.2.1 にて)
cc -c -O -pipe -Wreturn-type -Wcomment -Wredundant-decls -Wimplicit -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Winline -Wuninitialized -ansi -pedantic -nostdinc -I- -I. -I../.. -I../../../include -DKERNEL -include opt_global.h ../../net/if_loop.c
../../net/if_loop.c:83: warning: text following `#endif' violates ANSI standard
../../net/if_loop.c:252: warning: text following `#endif' violates ANSI standard
../../net/if_loop.c:94: warning: ANSI C does not allow extra `;' outside of a function
../../net/if_loop.c: In function `loopattach':
../../net/if_loop.c:119: warning: overflow in implicit constant conversion
間違い・追加情報を見付けた場合は、
修正案の投稿のしかた を読んだ上で、
QandA@jp.FreeBSD.org まで
お知らせください。