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

Struct Array and Item not within memory block

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



Joined: 13 Apr 2013
Posts: 8

View user's profile Send private message

Struct Array and Item not within memory block
PostPosted: Thu Apr 18, 2013 5:05 am     Reply with quote

I'm using PCWHD 4.138 compiler and writing a program. I've had to define some structs in the code, which are this;

Code:
typedef struct
{
   int hour;
   int min;
   int sec;
} chrono;

typedef struct
{
   int hour;
   int min;
   int sec;
   int1 enable;
} time;

typedef struct
{
   char UserName[MAX];                                   
   char Password[MAX];                                             
   time instance_list[INSTANCE_SIZE];                           
   chrono hist_list[HISTORY_SIZE];                               
   int1 valid;                                                   
   int counter;                                       
} user;


I have an array that keeps user structs, which is declared like this;

Code:
user List[MAX_USERS];


There seems to be a problem though, when I try to simulate it on Proteus. The addresses of variables in the List array seems to be overlapping, which causes undefined behavior.




I've googled the error not within memory block but couldn't find anything. Plus proteus seems to be thinking that one element of the user List is 84 bytes, which is way more than the real value. I've tried it with both PIC16F877 and PIC18F4620
temtronic



Joined: 01 Jul 2010
Posts: 9221
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Apr 18, 2013 5:23 am     Reply with quote

simple answer..
please read PIC101 sticky.

Your problem is inside Proteus,well known flaws exist within.Why 'everyone' thinks it's perfect is beyond me as it can't simulate any PIC properly.

This is NOT a Proteus forum,and no one here will waste their valuable time trying to patch Proteus.

I strongly suggest getting real PICs,write real code,burn the PIC and see what happens in the real world.After you do those 3 steps,report back, and several of the 'gang' will be able to show you how to get your code 'up and running'.

hth
jay
albus



Joined: 13 Apr 2013
Posts: 8

View user's profile Send private message

PostPosted: Thu Apr 18, 2013 5:28 am     Reply with quote

Chill man,

I know that proteus is flawed. For starters, it doesn't even recognize int1 data type.

It's just that I'm using struct in struct and arrays in arrays. That's why I asked if this might occur because of a flaw in code. I'll try it in real life and report back.


Edit: So I tried it on real hardware and there was no problem and for some magical reason even though cpu variables are still shown as in the picture, it worked fine in Proteus also.
In other words, problem solved.
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