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

Req; variables, pointers size

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



Joined: 16 Mar 2005
Posts: 2

View user's profile Send private message

Req; variables, pointers size
PostPosted: Wed Mar 16, 2005 3:53 pm     Reply with quote

Hello,

I would like to know some variables size for two mcus. I guess that it is tied to the architecture so it be different from pic16 to pic 18.

Could someone give :

For a PIC16F876A
------------------------
char *Var = ???
char Var = ???
short Var = ???
int Var = ???
long Var = ???

For a PIC18F6720
------------------------
char *Var = ???
char Var = ???
short Var = ???
int Var = ???
long Var = ???

I want these infos cause I have some weird compiler errors that doesn't allow me to do some stuff as ( on a pic16f876a ) :
char *Var = 0x100
the error telling me 0x110 isnt between [0..255].
This is kinda confusing, I cannot believe a pointer on a byte could be only 0 to 255, haha...
Mebbie it may be related to the #locate which is associated with

Thank you very much

Warm regards

Arnaud
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 16, 2005 4:12 pm     Reply with quote

For a PIC16F876A
------------------------
char *Var = 8 bits, but it can be 16 bits if you add: #use device *=16
char Var = unsigned 8 bits
short Var = 1 bit
int Var = unsigned 8 bits
long Var = unsigned 16 bits


Example of how to enable 16-bit pointers for the PCM compiler:

Code:

#include <16F876A.H>
#device *=16  // Put this statement on the next line after the #include.

main()
{

while(1);
}


For a PIC18F6720
------------------------
char *Var = 16 bits
char Var = unsigned 8 bits
short Var = 1 bit
int Var = unsigned 8 bits
long Var = unsigned 16 bits


It may be easier if you use CCS's alternate data types. Then you
can instantly see the size:
int1
int8
int16
int32
These are all unsigned.
amaye



Joined: 16 Mar 2005
Posts: 2

View user's profile Send private message

PostPosted: Thu Mar 17, 2005 2:29 am     Reply with quote

Ok, this new directive is working properly as expected

Thank you

Arnaud
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