Log in

View Full Version : Urgent help needed... Structs and compiling issues


Salik Syed
17-02-2006, 22:04
okay so i make a simple structure like this:

struct constants
{
int KP;
int KI;
int KD;
int div;
};



then reference it here:
struct constants pid[2]={{0,0,0,0},{0,0,0,0}};
this works fine and dandy but when i do this it gives me a linker error:

struct constants pid[4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};

What is going on I CANNOT figure it out! the linker says something like this:

idata_pid.o cannot fit the section. Section "idata_pid.o" length = 0x0000010a

please help...! i can't figure it out ... this is so simple yet frustrating

JonathanLKS
18-02-2006, 11:39
It sounds like you are using too much memory.
Try making the variables smaller like a short int or an unsigned char

Salik Syed
18-02-2006, 12:07
thats what i thought of as well... but doesn't a char take just as memory as an int ? i will try it though... i don't see why though... i mean watsons struct has 6-7 ints... maybe i have too many we'll see ... thanks

Dave Flowerday
18-02-2006, 13:18
but doesn't a char take just as memory as an int?
A char is 8 bits and an int is 16 bits when the MCC compiler is used.

Greg Ross
18-02-2006, 14:28
...this works fine and dandy but when i do this...:

struct constants pid[4]={{0,0,0,0},{0,0,0,0},{0,0,0,0},{0,0,0,0}};

...the linker says something like this:

idata_pid.o cannot fit the section. Section "idata_pid.o" length = 0x0000010a
Each module is allowed only 256 (0x100) bytes of data. When you added this declaration to pid.c, you pushed it over the limit by 10 (0x0a) bytes. You might be able to get around this limit by putting the declaration in another .c file, and reference it as an extern from pid.c.



Woah! post #2048! Sweeeet! :D

Salik Syed
18-02-2006, 20:36
Woah! post #2048! Sweeeet!

anyone that jubilates over having a post count equal to a power of two is a true nerd.

161 posts until i can celebrate ;) !