This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ram data corrupt

hello

I write program in one kind of RTOS. But some times  all the data in RAM are corrupt since I add some code

in functions, if continue add some code in the function, the data in RAM is OK.

Parents
  • Yes, virtually every 'C' compiler puts automatic variables on the stack.

    Sure, you can have a pointer to an auto variable - but you have to be certain that it will only ever be used while it remains valid.

    Once the function where the auto variable was defined returns, the pointer will no longer be valid.

    Google "lifetime" of variables in 'C' ...

Reply
  • Yes, virtually every 'C' compiler puts automatic variables on the stack.

    Sure, you can have a pointer to an auto variable - but you have to be certain that it will only ever be used while it remains valid.

    Once the function where the auto variable was defined returns, the pointer will no longer be valid.

    Google "lifetime" of variables in 'C' ...

Children