va_arg error on Linux 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 machi开发者_开发问答ne:
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 ?
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.
精彩评论