value of FALSE

  • Follow


Guys,

   Is it guaranteed that FALSE will always expand to value 0 and TRUE
to some non zero value.

   if (TRUE)  /* will this always be successful */

   if (FALSE)  /* will this always fail */


  thanks...
0
Reply junky_fellow (377) 8/11/2009 4:56:00 PM

"junky_fellow@yahoo.co.in" <junky_fellow@yahoo.co.in> writes:
>    Is it guaranteed that FALSE will always expand to value 0 and TRUE
> to some non zero value.
>
>    if (TRUE)  /* will this always be successful */
>
>    if (FALSE)  /* will this always fail */

Only if you define them that way.

The identifiers TRUE and FALSE are not defined in the standard C
language or library.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply kst-u (21484) 8/11/2009 5:08:05 PM


On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and TR=
UE
> > to some non zero value.
>
> > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> Only if you define them that way.
>
> The identifiers TRUE and FALSE are not defined in the standard C
> language or library.
>

stdbool.h has them though(in small letters), doesn't it?
"true" and "false"
0
Reply harsha.dsh (50) 8/12/2009 2:43:12 AM

On Aug 12, 10:43=A0am, dsriharsha <harsha....@gmail.com> wrote:
> On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> > > to some non zero value.
>
> > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > Only if you define them that way.
>
> > The identifiers TRUE and FALSE are not defined in the standard C
> > language or library.
>
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"

True. It's case sensitive, so names in different cases ain't identical.
0
Reply lovecreatesbeauty (723) 8/12/2009 5:41:09 AM

dsriharsha wrote:
> On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
>> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>>    Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>> to some non zero value.
>>>    if (TRUE)  /* will this always be successful */
>>>    if (FALSE)  /* will this always fail */
>> Only if you define them that way.
>>
>> The identifiers TRUE and FALSE are not defined in the standard C
>> language or library.
>>
> 
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"

Yes, and since C is case sensitive, that's a completely different issue. 
  stdbool.h is required to #define false so that it "expands to the 
integer constant 0" (7.16p3).
0
Reply jameskuyper (5171) 8/12/2009 9:51:54 AM

On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
> On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> > > to some non zero value.
>
> > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > Only if you define them that way.
>
> > The identifiers TRUE and FALSE are not defined in the standard C
> > language or library.
>
> stdbool.h has them though(in small letters), doesn't it?
> "true" and "false"

and stdbool is a C99 feature
0
Reply nick_keighley_nospam (4574) 8/12/2009 11:42:06 AM

On 11 Aug, 17:56, "junky_fel...@yahoo.co.in"
<junky_fel...@yahoo.co.in> wrote:

> =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and TRUE
> to some non zero value.

no, but zero is treated as false and any non-zero value is treated as
true.

> =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> =A0 =A0if (FALSE) =A0/* will this always fail */

depends how you define them


0
Reply nick_keighley_nospam (4574) 8/12/2009 11:44:41 AM

On Aug 12, 2:51=A0pm, James Kuyper <jameskuy...@verizon.net> wrote:
> dsriharsha wrote:
> > On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
> >> "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> >>> =A0 =A0Is it guaranteed that FALSE will always expand to value 0 and =
TRUE
> >>> to some non zero value.
> >>> =A0 =A0if (TRUE) =A0/* will this always be successful */
> >>> =A0 =A0if (FALSE) =A0/* will this always fail */
> >> Only if you define them that way.
>
> >> The identifiers TRUE and FALSE are not defined in the standard C
> >> language or library.
>
> > stdbool.h has them though(in small letters), doesn't it?
> > "true" and "false"
>
> Yes, and since C is case sensitive, that's a completely different issue.
> =A0 stdbool.h is required to #define false so that it "expands to the
> integer constant 0" (7.16p3).

Well yes.. C is case sensitive and everything.. I was just mentioning
that something to that effect(what the OP uses) does exist in C.
0
Reply harsha.dsh (50) 8/12/2009 4:35:20 PM

On Aug 12, 4:42=A0pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
wrote:
> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>
>
>
> > On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:
>
> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
> > > > =A0 =A0Is it guaranteed that FALSE will always expand to value 0 an=
d TRUE
> > > > to some non zero value.
>
> > > > =A0 =A0if (TRUE) =A0/* will this always be successful */
>
> > > > =A0 =A0if (FALSE) =A0/* will this always fail */
>
> > > Only if you define them that way.
>
> > > The identifiers TRUE and FALSE are not defined in the standard C
> > > language or library.
>
> > stdbool.h has them though(in small letters), doesn't it?
> > "true" and "false"
>
> and stdbool is a C99 feature

point being?
0
Reply harsha.dsh (50) 8/12/2009 4:35:56 PM

dsriharsha <harsha.dsh@gmail.com> writes:
> On Aug 12, 4:42�pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
> wrote:
>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>> > On Aug 11, 10:08�pm, Keith Thompson <ks...@mib.org> wrote:
>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>> > > > � �Is it guaranteed that FALSE will always expand to value 0 and TRUE
>> > > > to some non zero value.
>>
>> > > > � �if (TRUE) �/* will this always be successful */
>>
>> > > > � �if (FALSE) �/* will this always fail */
>>
>> > > Only if you define them that way.
>>
>> > > The identifiers TRUE and FALSE are not defined in the standard C
>> > > language or library.
>>
>> > stdbool.h has them though(in small letters), doesn't it?
>> > "true" and "false"
>>
>> and stdbool is a C99 feature
>
> point being?

The point being that most C implementations do not fully support C99,
so code that uses <stdbool.h> may not be 100% portable.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply kst-u (21484) 8/12/2009 6:05:03 PM

Keith Thompson <kst-u@mib.org> writes:
> dsriharsha <harsha.dsh@gmail.com> writes:
>> On Aug 12, 4:42 pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
>> wrote:
>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>>> > On Aug 11, 10:08 pm, Keith Thompson <ks...@mib.org> wrote:
>>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>> > > >    Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>> > > > to some non zero value.
>>>
>>> > > >    if (TRUE)  /* will this always be successful */
>>>
>>> > > >    if (FALSE)  /* will this always fail */
>>>
>>> > > Only if you define them that way.
>>>
>>> > > The identifiers TRUE and FALSE are not defined in the standard C
>>> > > language or library.
>>>
>>> > stdbool.h has them though(in small letters), doesn't it?
>>> > "true" and "false"
>>>
>>> and stdbool is a C99 feature
>>
>> point being?
>
> The point being that most C implementations do not fully support C99,
> so code that uses <stdbool.h> may not be 100% portable.

They don't need to fully support C99 in order to support <stdbool.h>,
in fact, believe it or not, they only need to support the stdbool 
subset of C99 in order to support it.

Phil
-- 
If GML was an infant, SGML is the bright youngster far exceeds 
expectations and made its parents too proud, but XML is the 
drug-addicted gang member who had committed his first murder 
before he had sex, which was rape. -- Erik Naggum (1965-2009)
0
Reply thefatphil_demunged (1558) 8/12/2009 10:59:29 PM

Phil Carmody <thefatphil_demunged@yahoo.co.uk> writes:
> Keith Thompson <kst-u@mib.org> writes:
>> dsriharsha <harsha.dsh@gmail.com> writes:
>>> On Aug 12, 4:42�pm, Nick Keighley <nick_keighley_nos...@hotmail.com>
>>> wrote:
>>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
>>>> > On Aug 11, 10:08�pm, Keith Thompson <ks...@mib.org> wrote:
>>>> > > "junky_fel...@yahoo.co.in" <junky_fel...@yahoo.co.in> writes:
>>>> > > > � �Is it guaranteed that FALSE will always expand to value 0 and TRUE
>>>> > > > to some non zero value.
>>>>
>>>> > > > � �if (TRUE) �/* will this always be successful */
>>>>
>>>> > > > � �if (FALSE) �/* will this always fail */
>>>>
>>>> > > Only if you define them that way.
>>>>
>>>> > > The identifiers TRUE and FALSE are not defined in the standard C
>>>> > > language or library.
>>>>
>>>> > stdbool.h has them though(in small letters), doesn't it?
>>>> > "true" and "false"
>>>>
>>>> and stdbool is a C99 feature
>>>
>>> point being?
>>
>> The point being that most C implementations do not fully support C99,
>> so code that uses <stdbool.h> may not be 100% portable.
>
> They don't need to fully support C99 in order to support <stdbool.h>,
> in fact, believe it or not, they only need to support the stdbool 
> subset of C99 in order to support it.

That is, of course, correct (assuming "the stdbool subset of C99"
includes the _Bool keyword).

It's also consistent with what I wrote.

(Well, mostly.  It's logically possible that all compilers support
<stdbool.h>, even though not all compilers fully support C99.
But I don't believe that's actually the case.)

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
0
Reply kst-u (21484) 8/12/2009 11:52:01 PM

On 13 Aug, 00:52, Keith Thompson <ks...@mib.org> wrote:
> Phil Carmody <thefatphil_demun...@yahoo.co.uk> writes:
> > Keith Thompson <ks...@mib.org> writes:
> >> dsriharsha <harsha....@gmail.com> writes:
> >>> On Aug 12, 4:42=A0pm, Nick Keighley <nick_keighley_nos...@hotmail.com=
>
> >>>> On 12 Aug, 03:43, dsriharsha <harsha....@gmail.com> wrote:
> >>>> > On Aug 11, 10:08=A0pm, Keith Thompson <ks...@mib.org> wrote:

<snip>

> >>>> > > The identifiers TRUE and FALSE are not defined in the standard C
> >>>> > > language or library.
>
> >>>> > stdbool.h has them though(in small letters), doesn't it?
> >>>> > "true" and "false"
>
> >>>> and stdbool is a C99 feature
>
> >>> point being?

to supply information


> >> The point being that most C implementations do not fully support C99,
> >> so code that uses <stdbool.h> may not be 100% portable.
>
> > They don't need to fully support C99 in order to support <stdbool.h>,
> > in fact, believe it or not, they only need to support the stdbool
> > subset of C99 in order to support it.
>
> That is, of course, correct (assuming "the stdbool subset of C99"
> includes the _Bool keyword).
>
> It's also consistent with what I wrote.
>
> (Well, mostly. =A0It's logically possible that all compilers support
> <stdbool.h>, even though not all compilers fully support C99.
> But I don't believe that's actually the case.)

it isn't. For various reasons people use old compilers.
0
Reply nick_keighley_nospam (4574) 8/13/2009 9:13:35 AM

12 Replies
42 Views

(page loaded in 0.128 seconds)

Similiar Articles:


















7/3/2012 8:00:57 AM


Reply: