Hi Friends!
In my project firmware is supposed to be compiled from C for several platforms (now Arduino, STM32 and javascript emulator). I want to figure out the convenient way to allow two arrays have different size on different platforms. :-?
Here are details (sorry for many letters below) - it is a basic language interpreter, so here are two "large" byte arrays - one for storing program and variables (as lines are entered or variables/arrays created) - and another for entering current line. Say, Arduino may have only 800+300 bytes for program+vars while for STM32 this could be 5kb+10kb.
Currently this is done awkwardly. Project has its "core" set of files and few files specific to each platform in folders "core", "ardubasic", "stm32" and "js". The arrays are declared in these "specific" files, like
this for arduino. Then they are then "extern"-ed in the "core" files - and
sizes are passed to init function at beginning.
Every time I forget how exactly it is done, I understand it is a completely wrong way. However I seem to lack professional experience with C (though I used it since school and work with other languages for years) and can't understand if there is a way to declare these sizes as defines in "specific" part - and then use these defines in "core" files... The problem is that core files don't know anything about specific ones - on contrary they are used like a library attached to specific ones.
And also I sometimes think that at least division between program and data should be made runtime-configurable... But this makes me even more lost then ever... :-( So thank you in advance for hints!