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

sizeof() returns an erroneous value with structure !!!

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



Joined: 12 Sep 2003
Posts: 32
Location: France (Paris)

View user's profile Send private message

sizeof() returns an erroneous value with structure !!!
PostPosted: Tue Jan 13, 2004 5:37 am     Reply with quote

Hi,

Here is a problem with PCHW v3.182 (and PIC18F6520)

here is the code :
typedef struct
{
BYTE Signature[3];
BYTE buffer[128];
}t_EE;

t_EE EE;

#define SizeSignature sizeof(EE.Signature)

==> the SizeSignature is 0x83 and not 3 !!!!!!!!!!
but if the structure size is lower than 128 bytes, there is no problem.

Is there a limitation of the size of a structure ???
Is someone have the same result ???

Thank you
Franck
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jan 13, 2004 1:49 pm     Reply with quote

That bug was reported here, on March 18, 2003.
http://www.ccsinfo.com/forum/viewtopic.php?t=3003

Also here, on Sept. 17, 2002
http://www.ccsinfo.com/forum/viewtopic.php?t=13886

Maybe if it gets reported one more time, it will get fixed ?
Rolling Eyes

Those complaints were about PCM, not PCH.
I did a test on vs. PCM vs. 3.183, to see how it's doing.
Not good. The following sample program displayed this result:

Size of Signature = 83

It should be 3.

#include "16F877.h"
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 8000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

typedef struct
{
BYTE Signature[3];
BYTE buffer[80]; // Use a smaller buffer size, for 16F877
}t_EE;

t_EE EE;

#define SizeSignature sizeof(EE.Signature)

//============================================
main()
{
char c;

c = SizeSignature;

printf("Size of Signature = %u ", c);

while(1);
}
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