public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] gcc issue ?
@ 2001-06-12 23:39 Ram Menon
  2001-06-13  0:14 ` Jim Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Ram Menon @ 2001-06-12 23:39 UTC (permalink / raw)
  To: linux-ia64

Hi,

Following program fails compilation on linux ia64 os, but works on 
other os's.

#include <stdarg.h>

main()
{

f(1, 'c', 10);
}

f(char a, ...)
{

int cval;
va_list     args;
va_start(args, a);

cval = va_arg(args, char);

}


[root@timba /root]# cc main.c -o main
main.c:10: warning: type mismatch with previous implicit declaration
main.c:6: warning: previous implicit declaration of `f'
main.c: In function `f':
main.c:16: `char' is promoted to `int' when passed through `...'
main.c:16: (so you should pass `int' not `char' to `va_arg')


Is va_arg(args, int) same as va_arg(args, char) for char arg ?.

thanks


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Linux-ia64] gcc issue ?
  2001-06-12 23:39 [Linux-ia64] gcc issue ? Ram Menon
@ 2001-06-13  0:14 ` Jim Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jim Wilson @ 2001-06-13  0:14 UTC (permalink / raw)
  To: linux-ia64

>cval = va_arg(args, char);

This isn't valid ISO C.  You must use promoted types when calling va_args,
and hence you must use int here, just like the error message says.

Older versions of gcc, and many other compilers tend to accept this, with
various results, e.g. sometimes it works, sometimes it doesn't.  New versions
of gcc always give an error at compile time.

>Following program fails compilation on linux ia64 os, but works on 
>other os's.

This isn't IA-64 specific behaviour.  If you use a new gcc, it will give this
same error on all systems.

Jim


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-06-13  0:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-06-12 23:39 [Linux-ia64] gcc issue ? Ram Menon
2001-06-13  0:14 ` Jim Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox