help on inconsistent printf() warning from gcc

Joel Sherrill joel.sherrill@oarcorp.com
Fri Oct 31 20:21:00 GMT 2014


On 10/31/2014 3:04 PM, Joel Sherrill wrote:
> On 10/31/2014 2:13 PM, Craig Howland wrote:
>> On 10/31/2014 02:49 PM, Joel Sherrill wrote:
>>> Hi
>>>
>>> ...
>>>
>>> I have attached correct and incorrect test cases. I am hoping
>>> someone here can give me a clue as to where to look. I am
>>> wondering if this is an inconsistency across targets in the
>>> C library. I did file this as GCC PR63301 but it was quickly
>>> closed as invalid. But I think the inconsistent generation of
>>> warnings is a bug.
>> Not that this changes the behavior, but the test cases are labeled backwards.  
>> After applying the wchar_t-to win_t correction that Myers points out, the 
>> correct format is %lc (per C99), while %C is non-standard.
>>
> Thanks. That is much more helpful. Hopefully I can resolve this
> Monday in the code and eliminate another handful of warnings.
>
> I rather feel stupid. :(
Hmm... I am confused now. Our source is based on FreeBSD hexdump.
This is from conv.c. The printf() is line 137. wc is still a wchar_t in the
current version.  They use %C so it must be a BSD-ism. 

http://svnweb.freebsd.org/base/head/usr.bin/hexdump/conv.c?revision=247753&view=markup

Any suggestions looking at the original source on how to fix this?
Is adding a cast to wint_t in the printf() at line 137 enough.

I just don't ever do wide character programming. :(

-- 
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



More information about the Newlib mailing list