【发布时间】:2012-05-11 19:09:40
【问题描述】:
我在win32中编码,我的程序实际上在vs中在调试模式下工作,但不是在发布模式下,也不是在vs之外。
int _tmain(int argc, _TCHAR* argv[])
{
//assert that there are 3 parameters.
assert(argc==4);
LPCTSTR inputPath = argv[1];
LPCTSTR sharedName = argv[2];
LPCTSTR logPath = argv[3];
有时 argc 不正确(超过 300000,而应该是 4),有时
LPCTSTR sharedName = argv[2];
行被忽略了!
在发布模式下调试该程序时,它会跳过它,当悬停在变量名上方时,什么也没有发生。
右键单击变量并选择添加监视时,我收到错误 logPath CXX0017: Error: symbol "logPath" not found
当然,我已将 vs 中的命令参数设置为“a b c”(不带引号)
可能是什么? 运行简化程序: // test.cpp : 定义控制台应用程序的入口点。 //
#include "stdafx.h"
#include "stdafx.h"
#include <windows.h>
#include <assert.h>
#include "conio.h"
int _tmain(int argc, _TCHAR* argv[])
{
assert(argc==4);
LPCTSTR inputPath = argv[1];
LPCTSTR sharedName = argv[2];
LPCTSTR logPath = argv[3];
_getch();
}
产生相同的结果。调试器只是跳转到 getch 行,如果我尝试添加 watch,我得到 logPath CXX0017: Error: symbol "logPath" not found
inputPath CXX0017:错误:找不到符号“inputPath”
sharedName CXX0017:错误:找不到符号“sharedName”
【问题讨论】:
-
只是好奇,你为什么要在realease模式下调试?
-
因为在调试模式下它可以工作,而在外部与它没有,我不知道为什么。
-
您能否提供更多详细信息,说明您观察到程序在调试模式和外部 VS 之间的行为有何不同?
-
assert(argc == 4)是一种完全不合适的故障模式。assert应该用于逻辑错误,而不是运行时错误。 -
程序在vs中以调试模式工作,但在外部不工作
标签: visual-studio-2010 winapi command-line-arguments commandargument