Hi All,
I need some help to understand: PASS_STRINGS=IN_RAM.
What real happen?
Code:
PASS_STRINGS=IN_RAM
#define str "Hello"
void main ()
{
while(1){
printf(str);
}}
The str is copied in ram when the Pic is programmed or is copied every time I call printf?
I hope the second one, right?. Manual:
A new way to pass constant strings
to a function by first copying the
string to RAM and then passing a
pointer to RAM to the function.
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
Posted: Sat Mar 18, 2017 4:45 am
It's basically copied when you use it. However internally it's slightly more complex. The 'buffer' used is much smaller than the longest string you use. So you can have:
Code:
const string1[] = "One test string";
const string2[] = "Another test string";
Then pass these to functions expecting 'char *', as if they are in RAM.
The buffer used is only a few bytes, but there is an added overhead, in that the compiler has to add code to 'know' how to handle this.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum