On Thu, Oct 17, 2002 at 08:59:30AM +0200, Aaron Ardiri wrote:
>> vs_start, va_end, and va_list are defined by the compiler... your tool set
>> should have come with a stdarg.h header file.
> 
>   for prc-tools:
> 
> #include <unix_stdarg.h>
> 
>   :P its hidden away inside the headers, dont include <stdarg.h> - it
>   doesn't work as planned :)

<stdarg.h> is provided by prc-tools' GCC, and is tailored for that GCC.
I use it every day without problems.  In what way have you found it to
not work as planned?

In general, when your tool set provides a particular standard header,
I would always recommend using that standard header in preference to any
unix_stdfoo.h, sys_foo.h, or armlet_stdfoo.h that might be found in a
Palm OS SDK or elsewhere.

The header provided by your tool vendor has the standard name and aims
to provide the standard behaviour you expect, and has been tuned for and
tested with your compiler.  A "standard" header provided by the SDK aims
for the lowest common denominator, often provides only an approximation
to the standard behaviour, and likely hasn't even been tested with your
compiler.

In particular, the Palm OS SDK's <unix_stdarg.h> implementation is
incorrect and will crash for varargs functions in which the last named
parameter is smaller than an int (when there is an int-or-larger vararg),
such as the following:

        void foo (char *a, char b, ...);

Furthermore, while usage such as va_arg(foo, char) is undefined in the
Standard, as a quality of implementation issue it's nice to make it have
the expected behaviour; GCC's <stdarg.h> does so, while the SDK's
<unix_stdarg.h> does not and will crash:

        void bar (int i, ...) {
          va_list args;
          char c, *cp;
          va_start (args, i);
          c = va_arg (args, char);  /* Std usage would have "int" here */
          cp = va_arg (args, char *);  /* Address error with unix_stdarg */
          /* ... */
          }

    John

-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to