View previous topic :: View next topic |
Author |
Message |
elliotg
Joined: 02 Nov 2005 Posts: 2
|
How to use/declare the BYTE and BOOLEAN data types? |
Posted: Wed Nov 02, 2005 11:59 pm |
|
|
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
|
|
Posted: Thu Nov 03, 2005 1:20 am |
|
|
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
|
|
Posted: Thu Nov 03, 2005 1:22 am |
|
|
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
|
|
Posted: Thu Nov 03, 2005 2:22 am |
|
|
Thanks for your prompt responses! |
|
|
|