Get argc is zero and argv is null when debugging codes in Visual C ++

I ran into a very strange problem today. I have created four configurations for my project, they are

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

      

Only X64|Release

, I always got the basic function of the two parameters that argc==0

, and argv==NULL

when you start to debug my code through F10/F11

. As in the other 3 configurations the parameters are ok! I tried to create a new project / solution several times but the problem still exists.

My IDE is visual studio 2012 on Win7 / x64, please help me find the problem, thanks!

+3


source to share


1 answer


The debugger is lying to you.



In release builds, Visual Studio often throws away too much information about optimizations applied to code, so viewport variables often print garbage values. An easy way to alleviate this situation is using the /d2Zi+

compile flag a
little . Just add it as an additional build option (Project Properties-> C ++ -> Command Line-> Additional Options) and you will see the correct values ​​again.

+3


source







All Articles