3

I have encounted a very strange problem today. I Created four configurations for my project, they are

X86|Debug
X86|Release
X64|Debug
X64|Release

Only in X64|Release, I always got main function's two parameters that argc==0 and argv==NULL when start debuging my code through F10/F11. Since in the other 3 configurations the parameters are OK! I've tried to create new project/solution several times but the problem still exists.

My IDE is visual studio 2012 in Win7/x64, Please help me to find the problem, Thanks!

2
  • Are you running this program through the debugger? Commented Aug 19, 2014 at 12:12
  • Yes, I press F10 to start debuging my program. only in X64|Release, the parameters are 0. very strange! Commented Aug 19, 2014 at 12:16

1 Answer 1

3

The debugger is lying to you.

In Release builds, Visual Studio often throws away too much information about the optimizations applied to the code, so the variable watch windows often print garbage values. An easy way to ease this situation a bit is using the /d2Zi+ compile flag. Just add it as an additional build option (Project Properties->C++->Command Line->Additional Options) and you should see the correct values again.

Sign up to request clarification or add additional context in comments.

2 Comments

Many thanks! I found the problem! When I printf out the parameters, they are ok!
@user2841150 If you find an answer useful, please consider upvoting it, or even mark it as an accepted answer to your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.