|
|
View previous topic :: View next topic |
Author |
Message |
franckcl
Joined: 12 Sep 2003 Posts: 32 Location: France (Paris)
|
sizeof() returns an erroneous value with structure !!! |
Posted: Tue Jan 13, 2004 5:37 am |
|
|
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
|
|
Posted: Tue Jan 13, 2004 1:49 pm |
|
|
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 ?
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);
} |
|
|
|
|
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
|