CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Are long and int16 really the same?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

Are long and int16 really the same?
PostPosted: Tue Sep 27, 2005 3:28 pm     Reply with quote

According to the compiler manual, a long and an int16 are the same. Is this correct? Should long = int32? Typically a long is at least 32 bits.

Regards,

Steve
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 27, 2005 3:38 pm     Reply with quote

Yes, in CCS a 'long' and 'int16' are the same.

Note that they are also both unsigned.
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PostPosted: Tue Sep 27, 2005 4:19 pm     Reply with quote

An int16 is unsigned? Wow, I would have never guessed that! Thanks, you just potentially save me a lot of headaches. So, for an integer of any type to be signed, it must explicitly be declared as signed? I have never seen a C compiler with this "feature". Is there a reason for it?

Regards,

Steve
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 27, 2005 4:30 pm     Reply with quote

Somewhere there is a post I think, by Ttelmah, that speculates on
why CCS did it this way, but I can't find it. But I did find
a whole thread of screaming on the topic. LOL.
http://www.ccsinfo.com/forum/viewtopic.php?t=1073&start=0
SteveW



Joined: 27 Sep 2005
Posts: 25

View user's profile Send private message

PostPosted: Tue Sep 27, 2005 5:08 pm     Reply with quote

Interesting thread. I am now very happy that I started reading the manual before using the product. I would have never considered that a default int would be unsigned. I can live with this quirk, but how many more are there? Back to my reading.

Thanks again,

Steve
Guest








PostPosted: Wed Sep 28, 2005 4:22 am     Reply with quote

It works the other way. I now code in CCS 99% of the time and try and use CCS "C" in the real world as well!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Sep 28, 2005 7:25 am     Reply with quote

It is always eye-opening for C++ programmers when I explain that I can't just add another flag to my old 16C54 code because I have already used the extra bits available in the Status register and adding another short would require a whole byte which I just don't have!
_________________
The search for better is endless. Instead simply find very good and get the job done.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Wed Sep 28, 2005 8:21 am     Reply with quote

yes, keep hold of all those spare bits. Don't use a byte when a bit will do.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group