View unanswered posts | View active topics It is currently Sat Nov 22, 2014 9:03 pm






Reply to topic  [ 4 posts ] 
#if 
Author Message
Expert

Joined: Tue Feb 28, 2012 3:10 pm
Posts: 195
Post #if
I know I am late to post this, and it has an easy work around, but if you could add this without affecting anything else;

#if true fails. I type that everytime, then end up changing it to 1 :|

so Boolean for pre-processor, please.

Mike

_________________
Mike aka Spiked3
http://www.spiked3.com


Tue Oct 09, 2012 5:48 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: #if
Mike,
Are you sure the C preprocessor recognizes the keyword "true"? I compiled the following code in Visual Studio and it took the #else path. (i.e. it printed "false"). So I don't think this is a bug although Visual Studio did not give me any compiler error. It just treated "true" as a "pre-processor variable" that contains a value 0. I don't have RobotC in front of me so I don't know what RobotC does. If it produces a compiler error, you can argue it is a bug. Nevertheless, I don't think it should treat "true" as a Boolean keyword.
Code:
#if true
    printf("true\n");
#else
    printf("false\n");
#endif


Tue Oct 09, 2012 6:00 pm
Profile
Expert

Joined: Tue Feb 28, 2012 3:10 pm
Posts: 195
Post Re: #if
Nope, I'm pretty sure it does not, since true is a boolean and c doesn't have those, however robotC does.

I could always #define TRUE 1 - as was done for so many years in C, then have a mixture of TRUE and true all over the place, that would look so, ummm, professional?

_________________
Mike aka Spiked3
http://www.spiked3.com


Tue Oct 09, 2012 6:17 pm
Profile
Site Admin
Site Admin

Joined: Wed Jan 24, 2007 10:42 am
Posts: 613
Post Re: #if
This is a pretty reasonable change - We'll include this in the next release (may not make today's private Beta however)

_________________
Timothy Friez
ROBOTC Developer - SW Engineer
tfriez@robotc.net


Wed Oct 10, 2012 12:22 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.