You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Nevo Hed <nh...@bamboom.com> on 2011/04/05 23:00:38 UTC

Default value for optional boolean

Hi Folks

What the correct way to specify a default value for an optional boolean?

I tried 'true' and 'false' but got errors:

struct AtscStrmRecordRequestT {
    1: optional bool bDoSomething = true,
    2: required string whatever;
}


$ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift
[ERROR:/rtmp/x.thrift:2] (last token was 'true')
Cannot use reserved language keyword: "true"


Thanks!
  -Nevo

Re: Default value for optional boolean

Posted by Richard Salz <rs...@us.ibm.com>.
> Pretty sure it's "1" for true, "0" for false. Ugly, I know. I'd be open 
to
> applying a patch to fix this, if you wanted to submit one. I'd 
appreciate a
> ticket in any case.

I started to take a look at this.  Boy, thrift sure reserves a lot of 
words for later use :)

        /r$

--
STSM, WebSphere Appliance Architect
https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/


Re: Default value for optional boolean

Posted by Bryan Duxbury <br...@rapleaf.com>.
Pretty sure it's "1" for true, "0" for false. Ugly, I know. I'd be open to
applying a patch to fix this, if you wanted to submit one. I'd appreciate a
ticket in any case.

On Tue, Apr 5, 2011 at 2:00 PM, Nevo Hed <nh...@bamboom.com> wrote:

> Hi Folks
>
> What the correct way to specify a default value for an optional boolean?
>
> I tried 'true' and 'false' but got errors:
>
> struct AtscStrmRecordRequestT {
>    1: optional bool bDoSomething = true,
>    2: required string whatever;
> }
>
>
> $ /opt/thrift-0.6.0/compiler/cpp/thrift --gen cpp /rtmp/x.thrift
> [ERROR:/rtmp/x.thrift:2] (last token was 'true')
> Cannot use reserved language keyword: "true"
>
>
> Thanks!
>   -Nevo
>