hi all, Structures in C are supposed to be a contiguous block of memory. But what if I need my structure to contain some data variables in RAM, and some constant that can be located in ROM? I don't want to leave the constant in RAM to waste its space. How can such a struct be declared? Thanks
"I think it would've been much more convenient if the two can be combined inside a single struct." Then it couldn't be a single structure, could it? "If C language does not support this method, do you think it's because it is not used often, or a bad practice? what specific aspect of it is 'bad'?" As Erik said, THINK about it: a structure is by definition a single contiuous block of memory; we're not talking about some "feature" or "limitation" of the 'C' language - that's the very nature of the beast! If it were simply a limitation of 'C', you'd be able to write your own implementation in Assembler; but think about it again: how could you have a single label in Assembler that allows you to access both XRAM and ROM...? "Now we need two structs, and pointers linking the two" You don't necessarily need pointers - it was just suggested that it might be a useful way to link them.