Problem_Const_2D_array_passing to function

Beta Testing discussion on mikroC PRO for PIC.
Post Reply
Author
Message
Saleem_Beg
Posts: 4
Joined: 26 Dec 2012 21:17

Problem_Const_2D_array_passing to function

#1 Post by Saleem_Beg » 26 Dec 2012 21:42

Please tell me how can I pass a constant two dimensional array to function.

The Problem is like this,

const int array[8][8] = {
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
};

void func(int value[][8])
{
}

void main()
{
func(array);
}

NOT HAPPENING......

but if I declare the array as only int its working,but the problem associated with it, is that,RAM is increasing 128 byte per two dimensional array.
and 2KB of RAM will be full if I declare several array.

I want to declare more than 50 array for my project purpose.But I m unable to pass the const array....


Please Help, I will be highly obliged...

User avatar
dejan.odabasic
mikroElektronika team
Posts: 2649
Joined: 30 Apr 2012 14:20

Re: Problem_Const_2D_array_passing to function

#2 Post by dejan.odabasic » 27 Dec 2012 15:23

Hello,

If you are sending an const int to function, then you should expect const int - function argument should also be const int.

Code: Select all

void func(const int value[][8])
{
}
Best regards.

Saleem_Beg
Posts: 4
Joined: 26 Dec 2012 21:17

Re: Problem_Const_2D_array_passing to function

#3 Post by Saleem_Beg » 27 Dec 2012 17:24

its working.....thank you very much :)

Post Reply

Return to “mikroC PRO for PIC Beta Testing”