Static Variables in functions

Hi If i deine varialbe as ‘Static’ inside a function is it in the global scope or in the stack ? For example: void func(void) { static int i = 0; }

Static Variables in functions

This is a C question, not a FreeRTOS question. …and the answer is neither…. as you show it it is a function scope static. That means it retains its value between calls to the function, so it cannot be on the stack. It also means the function is not thread safe, as all tasks that call the function will use the same copy of the variable.