C++错误 (202):命令令牌太长

发布于 2024-11-25 16:00:48 字数 513 浏览 1 评论 0原文

我有一个“黑匣子”问题,涉及当我运行离散事件模拟大约一分钟时出现的错误。一切工作正常,并且成功完成,但系统在模拟过程中的某个时刻一次打印以下消息:

Error (202): Command token too long

我从未见过类似的情况。我想知道它指的是什么“命令”。也许是我在程序中进行了多次的 system("...") 调用,以便绘制和可视化它生成的数据。

很抱歉,我无法提供任何代码,因为我不确定错误来自何处。是否有一种有效的方法来发现系统在何时生成此消息?或者无论如何,您在自己的 C++ 编程经验中是否遇到过这样的错误,并因此建议它可能来自哪里?

我正在使用 Ubuntu 11.04 并使用 GCC 进行编译。对于特别长(30 秒以上)的模拟,该错误会在运行时模拟期间出现,而在较短的情况下不会出现。我应该强调的是,“错误”不会停止代码的执行,并且实际上不会在模拟数据的可视输出中导致任何可见的错误。

I have a "black box" question about an error I get when I run a discrete event simulation for about a minute. Everything works fine, and it completes successfully, but the system prints the following message once at some point during the simulation:

Error (202): Command token too long

I've never seen anything like it. I wonder what "command" it's referring to. Perhaps it's system("...") call that I make several times in the program in order to plot and visualize the data it generates.

I'm sorry I can't provide any code as I'm not sure where the error is coming from. Is there an efficient way to discover at which point the system generates this message? Or in any case, have you encountered such an error in your own C++ programming experience, and thus suggest where it could possibly be coming from?

I'm using Ubuntu 11.04 and compiling with GCC. The error appears at run-time during the simulation for simulations that are especially long (30+ seconds), and doesn't appear in shorter cases. I should emphasize that the "error" doesn't stop the execution of the code and doesn't actually cause any visible errors in the visual output of the simulation data.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寒江雪… 2024-12-02 16:00:48

编写一个类似于以下的程序:

int trials 10000;
string str("ls ");
while( trials--)
{
system( str.c_str() );
str += "a";
cout << "chars in cmd =  " << trials << endl;
}

它将连续运行如下命令
ls、ls a、ls aa、ls aaa,同时将其所在的试用版打印到控制台。

如果您对错误的来源是正确的,最终它会收到有关“令牌太长”的相同错误消息,如果是这样,请告诉您 cmd 可能有多少个字符。然后将此限制编码到您真正的 C++ 程序中,这样它就不会发出错误。

如果它没有重现错误,请尝试增大 # 次试验,例如最多 100k。如果仍然没有发生,则错误可能来自其他地方。

write a program similar to the following:

int trials 10000;
string str("ls ");
while( trials--)
{
system( str.c_str() );
str += "a";
cout << "chars in cmd =  " << trials << endl;
}

It will successively run commands like
ls, ls a, ls aa, ls aaa, while simultaneously printing to the console what trial # it's on.

and if you're right about where the error is coming from, eventually it will get the same error message about "token too long", and if so, tell you how many characters the cmd may be. Then code this limit into your real C++ program so that it doesn't emit the error.

If it doesn't reproduce the error, try making # trials bigger, say up to 100k. If it still doesn't happen, the error is probably coming from somewhere else.

痕至 2024-12-02 16:00:48

它来自词法分析器,告诉您程序中的令牌之一(标识符/预过程令牌/等)相当长。检查您的代码,看看是否有任何长得离谱的字符串或预处理器标记。

It's coming from a lexer, telling you that one of the tokens (identifiers/preproc tokens/etc.) in your program is rather lengthy. Look through your code to see if there are any ridiculously long strings or preprocessor tokens.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文