Replies: 4 comments 3 replies
-
If you make your variables volatile, they will not be optimised out. |
Beta Was this translation helpful? Give feedback.
-
Volatile is used mostly i.c.w. interrupt functions. For the compiler thinks
these functions are never called. As a result the compiler can assume a
variable value is never changed or is never used. With volatile you force
the compiler to give it a dedicated location in memory.
If a compiler optimised away a volatile variable, the compiler is broken.
Op vr 26 mei 2023 18:39 schreef git2212 ***@***.***>:
… If you make your variables volatile, they will not be optimised out.
Yes that is true for most cases...some compilers ignore scoping suggested
by {...} the volatile keyword doesn't always work either... as I found out
... I am not entirely certain that the intended purpose for volatile
variables is to enable variables for debugging... I could be wrong
there has to be a way to control this somehow with a compiler flag (or two
or three) lol since it is a compiler behavior/optimization issue.
—
Reply to this email directly, view it on GitHub
<#1478 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACUEBZKPHNXVRJUZMN365DDXIDMEJANCNFSM6AAAAAAYQMNHFE>
.
You are receiving this because you commented.Message ID:
***@***.***
.com>
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
You'd wanna use debug_build_flags for that and include debug_build_flags = -O0 -ggdb3 -g3 |
Beta Was this translation helpful? Give feedback.
-
Hello,
I was wondering what the proper build flags would be for ensuring that the variables are not optimized out for a pico-debug session?
I have the following in my platformio.ini that should be relevant:
unfortunately many variables are still 'optimized out' while debugging as if the compiler ignored -O0 entirely. In fact it doesn't seem to matter what level of optimization is specified the results are always the same.
So not sure where this is unraveling, I don't think it's platformio as the build command seems to have all the right flags...
Suggestions?
Beta Was this translation helpful? Give feedback.
All reactions