[LinuxBIOS] proper way to pass an array between functions

Marcelo Coelho marcelocoelho at gmail.com
Tue May 22 13:25:43 CEST 2007


> raminit.c:97.37:  <which is where do_ram_command is defined, similar to
> spd_set_dram_size above>
> subscripted value is not a pointer

The gcc error tells the trueth: you have a pointer problem! :)

An array, in C, is like a pointer. When you do:
> unsigned long row_offsets[DIMM_SOCKETS * 2 - 1];

you'll get a pointer of type unsigned long with a size of
sizeof(unsigned long * (DIMM_SOCKETS * 2 - 1));

So, if you want to pass it into a function you have to define the
function with the parameter as being a pointer (and a good practice
would be also pass the size of the array).


> Okay, this is stupid, I know.
And there is no stupid questions! Just stupid answers.


http://en.wikipedia.org/wiki/C_(programming_language)#Data_structures


Cheers,
Marcelo




More information about the coreboot mailing list