<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xml:base="http://www.newlc.com" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
 <title>NewLC - Why use TBool vs. bool? - Comments</title>
 <link>http://www.newlc.com/en/topic-17445</link>
 <description>Comments for &quot;Why use TBool vs. bool?&quot;</description>
 <language>en</language>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37106</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote from: fig7&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;Anyway it would work fine if it was Symbian doing the hacking&amp;nbsp; &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/grin.gif&quot; alt=&quot;Grin&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;My guess is all they have to do is&lt;br /&gt;&lt;br /&gt;typedef bool TBool;&lt;br /&gt;#define ETrue true&lt;br /&gt;#define EFalse false&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Unfortunately, Symbian has just promised that Symbian 3rd Edition (OS 9) is going to be binary compatible from now on.&amp;nbsp; Which means they (or we) might have just lost the last opportunity to fix these problems that depend on compatibility with older editions.&amp;nbsp; &amp;nbsp;&lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/sad.gif&quot; alt=&quot;Sad&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;-euroq&lt;/div&gt;</description>
 <pubDate>Wed, 07 Feb 2007 16:26:16 +0100</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">comment 37106 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37105</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;That would be a disaster!&amp;nbsp; If you changed the headers of the SDK, every SDK method which uses a TBool would be compiled wrong in your code.&lt;/div&gt;&lt;br /&gt;Good to see you spotted that&amp;nbsp; &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/wink.gif&quot; alt=&quot;Wink&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;I suspect that your app simply wouldn&amp;#039;t link. The linker would be looking for Symbian OS functions using bools but it would only find ones that used ints!&lt;br /&gt;&lt;br /&gt;Anyway it would work fine if it was Symbian doing the hacking&amp;nbsp; &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/grin.gif&quot; alt=&quot;Grin&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;My guess is all they have to do is&lt;br /&gt;&lt;br /&gt;typedef bool TBool;&lt;br /&gt;#define ETrue true&lt;br /&gt;#define EFalse false&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;By the way, how do you know that the people at Symbian don&amp;#039;t use GCCE, what do they use instead?&lt;/div&gt;&lt;br /&gt;ARM don&amp;#039;t just make the processors they also provide a compiler for them:&lt;br /&gt;&lt;a href=&quot;http&amp;#58;//www.arm.com/products/DevTools/RealViewDEVELOP_Family.html&quot; target=&quot;_blank&quot;&gt;http://www.arm.com/products/DevTools/RealViewDEVELOP_Family.html&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Fri, 02 Feb 2007 02:14:23 +0100</pubDate>
 <dc:creator>fig7</dc:creator>
 <guid isPermaLink="false">comment 37105 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37104</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote from: fig7&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;I think it&amp;#039;s probably possible to just hack the header (e32std.h ?)&amp;nbsp; so that TBool becomes a bool. You might also be able to fix the annoying warnings that GCCE generates about ETrue and EFalse being different enums.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;That would be a disaster!&amp;nbsp; If you changed the headers of the SDK, every SDK method which uses a TBool would be compiled wrong in your code.&amp;nbsp; The worst thing is, probably a lot of your program would work and then all of a sudden crash.&amp;nbsp; &amp;nbsp;&lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/cry.gif&quot; alt=&quot;Cry&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;But it sure would be awesome to get rid of the ETrue/EFalse warnings, without having to cast every single comparison!&lt;br /&gt;&lt;br /&gt;By the way, how do you know that the people at Symbian don&amp;#039;t use GCCE, what do they use instead?&lt;/div&gt;</description>
 <pubDate>Thu, 01 Feb 2007 22:23:29 +0100</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">comment 37104 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37103</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote from: zingmagic&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;Apart from good practice hiding the variable &amp;#039;native&amp;#039; data types (just because youve disassembled the code and seen what it does with one complier on a couple of platforms, what makes you think all compliers will manage to do the same thing ?.) &lt;/div&gt;&lt;br /&gt;I did this on the only two that matter: the emulator and the device.&amp;nbsp; Also, I can positively say that the compiler is &lt;b&gt;always&lt;/b&gt; going to be able to optimize a native &lt;tt&gt;bool&lt;/tt&gt; type better than &lt;tt&gt;TBool&lt;/tt&gt;.&amp;nbsp; The two examples show this.&amp;nbsp; (However, I&amp;#039;m not saying that every use of a bool vs. int will be better optimized... obviously some code will always look the same, whether it&amp;#039;s an int or a bool).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;a primary reason is that you often dont save much, e.g. in a struct containing a bool followed by an int you will use 8 bytes regardless of bool only being a byte in size on the armi platforms since it has to align ints on 4 byte boundries. &lt;/div&gt;&lt;br /&gt;Yes I know about machine word alignment.&amp;nbsp; And once again, the compiler will handle this.&amp;nbsp; It will align them in structs, it will also pass bools in whatever method is best, and create optimized conditionals with bools better than ints.&amp;nbsp; Point is, you &lt;i&gt;will&lt;/i&gt; (well, &lt;i&gt;can&lt;/i&gt; in most instances) save something by switching from ints to bools.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;Bit like asking why use TInt instead of default compiler option for ints. Good practice + any complier differences and/or enchancements can be taken advantage of as required by a single change of the data type definition.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;Its no accident that practically all platforms choose to define their own data type sets... &lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Agreed.&amp;nbsp; C&amp;#039;s history has always been all about making the code work best for the platform it&amp;#039;s compiled for, not for &lt;i&gt;all&lt;/i&gt; platforms.&amp;nbsp; Which is why we have abstract data primitives (int, long), so that it maps to the machine the best.&amp;nbsp; So if you&amp;#039;re always using primitive data types, and expecting them to be a certain way cross-platform (i.e. 32 bits), you&amp;#039;re going to run into trouble.&amp;nbsp; C99 now has some new primitive types such as Int8, Int16, Int32, etc.&lt;br /&gt;&lt;br /&gt;Still, the point is that TBools aren&amp;#039;t as optimizable as bools.&lt;/div&gt;</description>
 <pubDate>Thu, 01 Feb 2007 22:18:37 +0100</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">comment 37103 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37102</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote from: fwojtek&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;With symbian 9 they had a long time to change most of suc**ng things in Symbian C++...&lt;br /&gt;&lt;br /&gt;I now think to use more of standard c++ on symbian 9. Developement will be easier, and code will bo more portable.&lt;/div&gt;Don&amp;#039;t even think about &amp;quot;standard C++&amp;quot; in Symbian, while you have to support &amp;quot;Leaves&amp;quot;. &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/cheesy.gif&quot; alt=&quot;Cheezy&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;But if &amp;quot;Leaves&amp;quot; were changed to C++ exceptions, THAT would be one and only MAJOR development speedup.&lt;/div&gt;</description>
 <pubDate>Tue, 30 Jan 2007 17:47:11 +0100</pubDate>
 <dc:creator>metalim</dc:creator>
 <guid isPermaLink="false">comment 37102 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37101</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;Apart from good practice hiding the variable &amp;#039;native&amp;#039; data types (just because youve disassembled the code and seen what it does with one complier on a couple of platforms, what makes you think all compliers will manage to do the same thing ?.) a primary reason is that you often dont save much, e.g. in a struct containing a bool followed by an int you will use 8 bytes regardless of bool only being a byte in size on the armi platforms since it has to align ints on 4 byte boundries. &lt;br /&gt;&lt;br /&gt;Bit like asking why use TInt instead of default compiler option for ints. Good practice + any complier differences and/or enchancements can be taken advantage of as required by a single change of the data type definition.&amp;nbsp; &lt;br /&gt;&lt;br /&gt;Its no accident that practically all platforms choose to define their own data type sets... &lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Tue, 30 Jan 2007 10:26:37 +0100</pubDate>
 <dc:creator>Holloway</dc:creator>
 <guid isPermaLink="false">comment 37101 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37100</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;They probably figured this would break backwards compatibility.Â  But with the release of Symbian 3rd Edition, as it is a binary-break release, this would have been a perfect time to change it.&lt;/div&gt;&lt;br /&gt;Yes, it would and they should have done it. But inevitably they had to find the right balance between changing things and maintaining backwards compatibility. It probably wasn&amp;#039;t something that was considered very important (and in the big scheme of things it isn&amp;#039;t). The key changes were the new kernel, platform security,Â  and the change over to use a completely new tool chain (GCCE / ARM compilers). Those were the things thatÂ  really mattered.&lt;br /&gt;&lt;br /&gt;What&amp;#039;s most annoying about them not changing this is that GCCE generates warnings every time you use ETrue and EFalse in the same expression (e.g bigY = (y&amp;gt;2) ? ETrue : EFalse). Of course the people at Symbian wouldn&amp;#039;t have noticed this as they don&amp;#039;t use GCCE!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;I also cant figure out why to use TInt instead of int???&lt;/div&gt;&lt;br /&gt;For me this is all about good object orientated design. That everything in your code has a clear purpose: any class of objects beginning with T are essentially passive blocks of data. Any class beginning with R represent a handle to a resource of some kind (which you &amp;quot;borrow&amp;quot; from the system). Any objects of C classes are actors within your program: they are things that &amp;quot;do stuff&amp;quot;.&lt;br /&gt;&lt;br /&gt;In terms of making code more portable my advice is to always try to seperate your code into the components that have to be portable and those that have to interface with the OS. In the portable parts you may as well use bools and standard C++ exceptions (these work on Symbian now, or at least I think they do. Can somebody confirm this?) but in the OS specific stuff I would continue to follow the Symbian coding guidelines.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 29 Jan 2007 23:44:30 +0100</pubDate>
 <dc:creator>fig7</dc:creator>
 <guid isPermaLink="false">comment 37100 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37099</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;With symbian 9 they had a long time to change most of suc**ng things in Symbian C++...&lt;br /&gt;&lt;br /&gt;I now think to use more of standard c++ on symbian 9. Developement will be easier, and code will bo more portable. I use bool for my staff and TBool only if its needed by some symbian functions.... &lt;br /&gt;&lt;br /&gt;I also cant figure out why to use TInt instead of int??? This works the same. Only convetion is another... &lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Mon, 29 Jan 2007 22:15:13 +0100</pubDate>
 <dc:creator>fwojtek</dc:creator>
 <guid isPermaLink="false">comment 37099 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37098</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote from: fig7&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;Although only a single bit would theoretically be necessary to represent a &lt;br /&gt;Boolean, a machine word is used instead, so that these quantities can be easily &lt;br /&gt;passed. Also, TBool must map onto int because of C++&amp;#039;s interpretation of &lt;br /&gt;operands in conditional expressions.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;One wise thing I learned in school is to never try to outsmart the compiler.&amp;nbsp; The compiler can figure out the best way to pass a bool (if it wants to send the bool as 4 bytes to align it to a machine word, that&amp;#039;s fine with me).&amp;nbsp; From now on in, I&amp;#039;m using exclusively bool instead of TBool.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;quoteheader&quot;&gt;Quote&lt;/div&gt;&lt;div class=&quot;quote&quot;&gt;On implementations of Symbian OS in which the compiler supports the ANSI-recommended bool type, TBool will be typedef&amp;#039;ed to bool instead of int.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;They probably figured this would break backwards compatibility.&amp;nbsp; But with the release of Symbian 3rd Edition, as it is a binary-break release, this would have been a perfect time to change it.&lt;br /&gt;&lt;br /&gt;-euroq&lt;/div&gt;</description>
 <pubDate>Mon, 29 Jan 2007 20:52:03 +0100</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">comment 37098 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37097</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;If you look in the headers you&amp;#039;ll probably find that TBool is typedef as an int (or a TInt)&lt;br /&gt;It&amp;#039;s for historical reasons really, early compilers didn&amp;#039;t have a bool type. I&amp;#039;m not sure why Symbian haven&amp;#039;t changed it: probably because &amp;quot;they say that if it isn&amp;#039;t broke don&amp;#039;t fix it&amp;quot;&lt;br /&gt;&lt;br /&gt;More to the point your analysis is correct: that the compiler should be able to optimise better if it knows a variable can only have true or false values.&lt;br /&gt;&lt;br /&gt;I think it&amp;#039;s probably possible to just hack the header (e32std.h ?)Â  so that TBool becomes a bool. You might also be able to fix the annoying warnings that GCCE generates about ETrue and EFalse being different enums.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Just checked the header file (e32def.h):&lt;br /&gt;&amp;nbsp;&lt;br /&gt;/**&lt;br /&gt;@publishedAll&lt;br /&gt;@released&lt;br /&gt;&lt;br /&gt;Boolean type which takes the value either ETrue or EFalse.&lt;br /&gt;&lt;br /&gt;Although only a single bit would theoretically be necessary to represent a &lt;br /&gt;Boolean, a machine word is used instead, so that these quantities can be easily &lt;br /&gt;passed. Also, TBool must map onto int because of C++&amp;#039;s interpretation of &lt;br /&gt;operands in conditional expressions.&lt;br /&gt;&lt;br /&gt;On implementations of Symbian OS in which the compiler supports the ANSI-recommended &lt;br /&gt;bool type, TBool will be typedef&amp;#039;ed to bool instead of int.&lt;br /&gt;*/&lt;br /&gt;typedef int TBool;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I guess they forgot to change itÂ  &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/shocked.gif&quot; alt=&quot;Shocked&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;/div&gt;</description>
 <pubDate>Sat, 27 Jan 2007 00:21:34 +0100</pubDate>
 <dc:creator>fig7</dc:creator>
 <guid isPermaLink="false">comment 37097 at http://www.newlc.com</guid>
</item>
<item>
 <title>Re: Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445#comment-37096</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;My guesses are as follows:&lt;br /&gt;- TBool starts with a &amp;#039;T&amp;#039;, whereas &amp;#039;bool&amp;#039; doesn&amp;#039;t ==&amp;gt; remember TAny and coding convention!&lt;br /&gt;- Maybe &amp;#039;bool&amp;#039; keyword was not available when Symbian basic datatypes were worked out?&lt;br /&gt;&lt;br /&gt;I don&amp;#039;t think the reason is more complex!&amp;nbsp; &lt;img src=&quot;/en/sites/all/modules/smf_filter/smf_smileys/rolleyes.gif&quot; alt=&quot;Roll Eyes&quot; border=&quot;0&quot; /&gt;&lt;br /&gt;&lt;br /&gt;Tote&lt;/div&gt;</description>
 <pubDate>Fri, 26 Jan 2007 23:55:53 +0100</pubDate>
 <dc:creator>tote</dc:creator>
 <guid isPermaLink="false">comment 37096 at http://www.newlc.com</guid>
</item>
<item>
 <title>Why use TBool vs. bool?</title>
 <link>http://www.newlc.com/en/topic-17445</link>
 <description>&lt;div class=&quot;smf-content&quot;&gt;&lt;/div&gt;&lt;p&gt;&lt;a href=&quot;http://www.newlc.com/en/topic-17445&quot;&gt;read more&lt;/a&gt;&lt;/p&gt;</description>
 <comments>http://www.newlc.com/en/topic-17445#comments</comments>
 <category domain="http://www.newlc.com/en/forums/symbian-c">Symbian C++</category>
 <pubDate>Fri, 26 Jan 2007 19:51:43 +0100</pubDate>
 <dc:creator>euroq</dc:creator>
 <guid isPermaLink="false">16977 at http://www.newlc.com</guid>
</item>
</channel>
</rss>
