I am working on an embedded systems project, so i am dealing with limited memory. I have this huge array of strings in C, it is basically an array of 31 bitmaps. I have it in a separate file called images.c and the header file is images.h, when i include it in main.c file it would take a huge chunk of memory. My question is, if i include the file inside a function and would that array take memory when the function is called? for example
#include <stdio>
void foo(){
#include "images.h"
// do stuff with the array of bitmaps
}
int main(){
//logic to sometimes call foo
}
would this work? will the array be a local variable in the function and its memory location would be cleared once the function is terminated?
Also am I understanding this correct? I understand that local variables are only local to the scope they are in and cannot be called outside it, but memory wise, is their location in memory actually cleared up? as if they were never there? similar to how a garbage collector works?
#includeline. So if it will produce any meaningful code, it will compile and do whatever it does.#include. For the first I recommend to make a minimal reproducible example with a a tiny pice of coded inside the header. I recommend to be clearer about the content of images.c, main.c and images.h. I.e. by making actual mres in each case.constand/or de-/compression..h, for example#include "images.dat"or#include "images.inc"