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 support@ccsinfo.com

How to use/declare the BYTE and BOOLEAN data types?

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



Joined: 02 Nov 2005
Posts: 2

View user's profile Send private message

How to use/declare the BYTE and BOOLEAN data types?
PostPosted: Wed Nov 02, 2005 11:59 pm     Reply with quote

How do I use or declare the BYTE and BOOLEAN data types using PCW C Compiler? When I try to use them, the compiler complains that it is "expecting a , or )". Should these be standard data types? I don't see them in the help file, however, many of the examples supplied with the compiler utilize these types.


Thanks
Foppie



Joined: 16 Sep 2005
Posts: 138
Location: The Netherlands

View user's profile Send private message Send e-mail Visit poster's website MSN Messenger

PostPosted: Thu Nov 03, 2005 1:20 am     Reply with quote

CCS does not know byte, instead use int or char for example. Boolean is also not known, use short or int1 instead.

There is a preprocessor directive #BYTE
Quote:
Syntax: #byte id = x

Elements: id is a valid C identifier,
x is a C variable or a constant

Purpose: If the id is already known as a C variable then this will locate the variable at address x. In this case the variable type does not change from the original definition. If the id is not know a new C variable is created and placed at address x with the type int (8 bit).


Warning: In both cases memory at x is not exclusive to this variable. Other variables may be located at the same location. In fact when x is a variable then id and x share the same memory location.


There is also the option to define BYTE and BOOLEAN as follows:
Code:
#define BYTE int
#define BOOLEAN short
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 03, 2005 1:22 am     Reply with quote

Quote:
I don't see them in the help file

Look in the .H file for your PIC. The .H files are in the following folder:
C:\Program Files\Picc\Devices

Near the beginning of the .H file, you will see this:
Code:

#define BYTE int
#define BOOLEAN short int


Note that in CCS, an "int" is an 8-bit unsigned value.

A "short int" is a 1-bit value.
elliotg



Joined: 02 Nov 2005
Posts: 2

View user's profile Send private message

PostPosted: Thu Nov 03, 2005 2:22 am     Reply with quote

Thanks for your prompt responses!
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