This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
wchar_t printf() format warning
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>
- Date: Wed, 18 Mar 2015 16:29:58 -0500
- Subject: wchar_t printf() format warning
- Authentication-results: sourceware.org; auth=none
Hi
I am returning to this issue. This appears to be similar to the
intptr_t issue but with wchar_t. We get a printf() warning on
targets where wchar_t is defined is defined as "long int" and
not on targets where it is "int". This appears to be because
of a conflict in the definition of __WINT_TYPE__ and
__WCHAR_TYPE__ by gcc. I am open to suggestions on how
to resolve this.
$ sparc-rtems4.11-gcc -dM -E - </dev/null | grep WCHAR_TYPE
#define __WCHAR_TYPE__ long int
$ i386-rtems4.11-gcc -dM -E - </dev/null | grep WCHAR_TYPE
#define __WCHAR_TYPE__ int
$ sparc-rtems4.11-gcc -dM -E - </dev/null | grep WINT_TYPE
#define __WINT_TYPE__ unsigned int
$ i386-rtems4.11-gcc -dM -E - </dev/null | grep WINT_TYPE
#define __WINT_TYPE__ unsigned int
sparc generates this warning but i386 does not:
$ sparc-rtems4.11-gcc -Wall -c wc.c
wc.c: In function 'f':
wc.c:10:3: warning: format '%lc' expects argument of type 'wint_t', but
argument 4 has type 'wchar_t' [-Wformat=]
(void)printf("%*s%lc\n", pad, "", wc);
^
wc.c:10:3: warning: format '%lc' expects argument of type 'wint_t', but
argument 4 has type 'wchar_t' [-Wformat=]
This is the test case:
=================
#include <stdio.h>
#include <wchar.h>
void f(void)
{
int pad = 10;
wchar_t wc = 'a';
(void)printf("%*s%lc\n", pad, "", wc);
}
=================
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985