Linux i386 上的 va_arg 错误

发布于 2024-11-14 13:06:38 字数 991 浏览 4 评论 0原文

我正在 Pro*C 代码中开发 DEBUG 消息打印功能。我在以下行中收到错误:

fmt = va_arg(args, char *);

错误如下:

Syntax error at line 672, column 40, file commonutil_x.pc:
Error at line 672, column 40 in file commonutil_x.pc
             fmt = va_arg(args, char * ); 
.......................................1
PCC-S-02201, Encountered the symbol ")" when expecting one of the following:

   ( * & + - ~ ! ^ ++ -- ... sizeof, an identifier,
   a quoted string, a numeric constant,
The symbol "..." was substituted for ")" to continue.

我的机器操作系统信息如下:

Linux Babo 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:34:33 EDT 2009 i686 i686 i386 GNU/Linux

但我在一个小型 C 程序中编写了相同的代码,它被编译并工作。 谁能告诉我为什么它在 Pro*C 中不起作用? 还在 x86_64 Linux 机器上编译了我的较大 Pro*C 程序,它编译时没有任何错误。以下是有关第二台机器的完整信息:

Linux Habo 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

请帮助我为什么它可以在 x86_64 上工作而不能在 i386 上工作?

I am developing a DEBUG message printing function in my Pro*C code. I am getting error on following line:

fmt = va_arg(args, char *);

The error is as follow:

Syntax error at line 672, column 40, file commonutil_x.pc:
Error at line 672, column 40 in file commonutil_x.pc
             fmt = va_arg(args, char * ); 
.......................................1
PCC-S-02201, Encountered the symbol ")" when expecting one of the following:

   ( * & + - ~ ! ^ ++ -- ... sizeof, an identifier,
   a quoted string, a numeric constant,
The symbol "..." was substituted for ")" to continue.

My machine os informations are as following:

Linux Babo 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:34:33 EDT 2009 i686 i686 i386 GNU/Linux

But I wrote the same code in a small C program it get compiled and worked.
Can any one let me know why it is not working in Pro*C?
Also compiled my larger Pro*C program on a x86_64 linux machine, it get compiled without any errors. Here are the full information about second machine:

Linux Habo 2.6.18-128.el5 #1 SMP Wed Dec 17 11:41:38 EST 2008 x86_64 x86_64 x86_64 GNU/Linux

Please help me why it is working on x86_64 and not working on i386 ?

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

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

发布评论

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

评论(1

与君绝 2024-11-21 13:06:38

鉴于您混淆了 32 位 Pro*C 预编译器,但没有混淆 64 位版本,您可能遇到了 Pro*C 预编译器中的错误。

建议:将产生错误的日​​志记录函数移至单独的纯 C 源文件中,并在不使用 Pro*C 编译器的情况下进行编译。

考虑到错误消息的性质,另一种选择是将 char * 替换为普通类型名称。很明显,Pro*C 预编译器期望 * 是乘法符号而不是类型名称的一部分。

typedef char *charptr;

fmt = va_arg(args, charptr);

在我看来,这不如分离编译好。

我不确定它是否可行(而且很可能不明智),但您可以考虑在将源代码提交到 Pro*C 预编译器之前运行 C 预处理器。不推荐,但它可能会解决问题。

Given that you've confused the 32-bit Pro*C precompiler but not the 64-bit version, you have probably hit a bug in the Pro*C precompiler.

Recommendation: move the logging function that gives an error into a separate, pure C source file, and compile that without the Pro*C compiler.

Another option, given the nature of the error messages, is to replace the char * with a plain type name. It is fairly clear that the Pro*C precompiler is expecting that * to be a multiplication symbol rather than part of a type name.

typedef char *charptr;

fmt = va_arg(args, charptr);

This is not as good as separating the compilation, in my view.

I'm not sure whether it is feasible (and it very probably is not sensible), but you could consider running the C preprocessor over the source before submitting it to the Pro*C precompiler. Not recommended, but it might resolve the problem.

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