Date: Thu, 29 Dec 2011 19:44:03 -0800 From: mdf@FreeBSD.org To: "Sean C. Farley" <scf@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Ed Schouten <ed@freebsd.org> Subject: Re: svn commit: r228878 - head/include Message-ID: <CAMBSHm8ZXNQ0CJXFFHAO5DaeTLJOZy73hBH=FoLjNUvn7%2BPqKQ@mail.gmail.com> In-Reply-To: <alpine.BSF.2.02.1112291617110.4588@thor.farley.org> References: <201112252015.pBPKFfZ1073959@svn.freebsd.org> <alpine.BSF.2.02.1112291617110.4588@thor.farley.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 29, 2011 at 6:54 PM, Sean C. Farley <scf@freebsd.org> wrote: > On Sun, 25 Dec 2011, Ed Schouten wrote: > >> Author: ed >> Date: Sun Dec 25 20:15:41 2011 >> New Revision: 228878 >> URL: http://svn.freebsd.org/changeset/base/228878 >> >> Log: >> =A0Remove unneeded guard. >> >> =A0There is no reason why <stdbool.h> needs an include guard. It is alre= ady >> =A0protected by __bool_true_false_are_defined. >> >> Modified: >> =A0head/include/stdbool.h >> >> Modified: head/include/stdbool.h >> >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> --- head/include/stdbool.h =A0 =A0 =A0Sun Dec 25 18:15:31 2011 =A0 =A0 = =A0 =A0(r228877) >> +++ head/include/stdbool.h =A0 =A0 =A0Sun Dec 25 20:15:41 2011 =A0 =A0 = =A0 =A0(r228878) >> @@ -26,9 +26,6 @@ >> =A0* $FreeBSD$ >> =A0*/ >> >> -#ifndef _STDBOOL_H_ >> -#define =A0 =A0 =A0 =A0_STDBOOL_H_ >> - >> #ifndef __bool_true_false_are_defined >> #define __bool_true_false_are_defined =A0 1 >> >> @@ -44,5 +41,3 @@ typedef =A0 =A0 =A0 int =A0 =A0 _Bool; >> >> #endif /* !__cplusplus */ >> #endif /* __bool_true_false_are_defined */ >> - >> -#endif /* !_STDBOOL_H_ */ > > > I just thought of this while reviewing the change: =A0should > __bool_true_false_are_defined be set only if __cplusplus is not set? =A0I= t > should be set for C99, but I wonder if it should be set for C++. My quick googling didn't show anything at all about the C++ standard and stdbool.h or __bool_true_false_are_defined. It was probably originally set because bool, true, and false are all C++ keywords so certain code that wanted to ifdef on them didn't also need to check __cplusplus. > Also, is there a style requirement that the guard for a header file be ba= sed > off of the name of the file? =A0I did not see anything obvious for this w= ithin > style(9), but I am curious. I think it's just common use to make sure different headers use a different include guard, so they only protect their contents, not any other file's. The C standard only mentions the symbols bool, true, false, and __bool_true_false_are_defined in regards to stdbool.h. Cheers, matthew
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm8ZXNQ0CJXFFHAO5DaeTLJOZy73hBH=FoLjNUvn7%2BPqKQ>