C++ argv 包含未知参数

c++ argv contains unknown arguments

在调试我的程序时,我在调试器中看到 argv 包含我没有编写的参数。 第一个参数是我的可执行文件路径,但它包含很多参数,其中大部分甚至无法访问。

如您所见,我正在使用 CLion,并且在 运行 我的程序中没有接受任何参数。它可以是什么?

您必须查看变​​量 argc 以了解有效参数的数量。

您可以在 argv[1000000] 处继续向下查看数组,但这并不意味着那里有任何有用的东西。

查看 argv[argc-1] 以外的任何元素都是没有意义的。不要这样做。

在你的情况下,我相信 argc == 1,唯一有效的参数是 argv[0],这是你的程序的名称,serverRun.exe

您看到的内容不应该被使用。调试器很可能会利用它来跟踪不需要的行为,例如溢出。地址包含魔法调试值

来自wiki

Magic debug values are specific values written to memory during allocation or deallocation, so that it will later be possible to tell whether or not they have become corrupted, and to make it obvious when values taken from uninitialized memory are being used. Memory is usually viewed in hexadecimal, so memorable repeating or hexspeak values are common.

Numerically odd values may be preferred so that processors without byte addressing will fault when attempting to use them as pointers (which must fall at even addresses). Values should be chosen that are away from likely addresses (the program code, static data, heap data, or the stack).

例如:

ABABABABMicrosoft 的调试 HeapAlloc() 用于在分配堆内存后标记“无人区”保护字节。

FEEEFEEE: "Fee fee",被微软的debug HeapFree()用来标记释放的堆内存。一些附近的内部簿记值也可能将高位字设置为 FEEE。

...