Net beans optimized out

Hello every one!
I use Net Beans on Arch Linux. How I turn off optimization in g++, for view values of variables?
I'am trying:
1. "Project properties" > "C++ Compiler" > "Additional options" added -O0.
2. I use "volatile" before variable. For example volatile int length = strlen(str)

But it's, don't work ((
What exactly doesn't work? Can you describe how you're building and running it?
What is the full compiler command produced?

If you need to view values of variables, I assume that means you're debugging.
Are you turning on debugging symbols?
https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html
Try adding -g.

Also, does this article help?
https://netbeans.org/kb/docs/cnd/debugging.html
Last edited on
When I view variable value, I see "<optimized out>". I building and running as described https://netbeans.org/kb/docs/cnd/debugging.html. I click "Clean and building project" > "Debug project".
Screenshot https://ibb.co/mRCbxyB. I note, if place string int length = strlen(str); (as view the screenshot) in constructor, value of variable "<optimized out>", but place in main(), value viewed correct. I try adding -g, but not working.

Your screenshot has gone.
Hmmm... It's strange... May be you copy link with last dot? Alternative link https://pictr.com/image/0CHzSx
Last edited on
It might be because you don't use length for anything.
Peter87, yes. You right, if I use variable below, then I see value. Can I view value without use variable?
I don't know. What's the point of the variable if you're not using it?
I heave read: "if I see "<optimized out>", and don't use variable, then will adding option -O0 into compilation string". It's don't working. Thank's every body!
Topic archived. No new replies allowed.