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

pointers to const struct.

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



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Oct 02, 2010 12:23 pm     Reply with quote

If you don't find a work-around for the problem in the forum archives,
then email CCS Support a short (but compilable) example.

This is what I mean by a short example. In fact, it could be shorter.
You don't need your ppout() routine to show the problem. Just a simple
printf of the sizeof() result is enough. You can run this in MPLAB simulator
and study the problem.
Code:

#include <18F452.H>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

typedef struct{
 int8 s1[5];
 int8 s2[5];
 int8 s3[5];
}pump_;


const pump_ pump[2]={
1,2,3,4,5,  //p1 s1
1,2,3,4,5,
1,2,3,4,5,  //p1 s3

1,2,3,4,5,  //p2 s1
1,2,3,4,5,
1,2,3,4,5}; //p2 s3

//==============================
void main()
{
int8 result;

result = sizeof(pump[0].s1);

printf("%x \r", result);

while(1);
}

I worked on your problem briefly. I tried to fix it by type-casting the
structure reference in the sizeof statement to _pump, and that changed it
to 0F (from 1e) so maybe it helped, but it's not the solution. For all I
know, there might be a solution in the forum archives, maybe even by
me, but I don't have time to search for it. If you own the compiler then
you can email CCS support about it. Maybe they might help, or maybe
fix it in the next version.
hmmpic



Joined: 09 Mar 2010
Posts: 314
Location: Denmark

View user's profile Send private message

PostPosted: Sat Oct 02, 2010 12:50 pm     Reply with quote

Thanks for testing it out, then it's not just me. I will let it go for now and just use the exact array count.
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