wpintf()与printf()的冲突

==========================================
wprintf() conflicts with printf().  glibc bug?
==============================================


On linux federa 10 beta, calling wprintf() following printf(),
wprintf() seems doing nothing. Is it a glibc bug?


steve yee <yitonglu@gmail.comwrites:
On linux federa 10 beta, calling wprintf() following printf(),
wprintf() seems doing nothing. Is it a glibc bug?
No. All streams may have an orientation (wide or not) but they all
start with none. The first operation will set it thereby rendering
the "other" family of functions invalid. You can test and/or set it
using the fwide function.

On Nov 10, 8:24 pm, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
steve yee <yiton...@gmail.comwrites:
On linux federa 10 beta, calling wprintf() following printf(),
wprintf() seems doing nothing$B!%(BAnd vice versa. Is it a glibc bug?

No. All streams may have an orientation (wide or not) but they all
start with none. The first operation will set it thereby rendering
the "other" family of functions invalid. You can test and/or set it
using the fwide function.

--
Ben.
Yes. The fwide() can set an orientation. But it the orientation can
not be changed once set. While on AIX printf() and wprintf() do not
interfere with each other.

steve yee <yitonglu@gmail.comwrites:
On Nov 10, 8:24 pm, Ben Bacarisse <ben.use...@bsb.me.ukwrote:
>steve yee <yiton...@gmail.comwrites:
On linux federa 10 beta, calling wprintf() following printf(),
wprintf() seems doing nothing. Is it a glibc bug?

No. All streams may have an orientation (wide or not) but they all
start with none. The first operation will set it thereby rendering
the "other" family of functions invalid. You can test and/or set it
using the fwide function.

--
Ben.
Best not to quote sigs.

Yes. The fwide() can set an orientation. But it the orientation can
not be changed once set.
That is true. If an implementation permits such a change, it does so
as an extension and a portable program should avoid relying on it.

While on AIX printf() and wprintf() do not
interfere with each other.
Then that is a perfectly legal extension. Section 7.19.2 paragraph 5
says (in part):

"Byte input/output functions shall not be applied to a wide-oriented
stream and wide character input/output functions shall not be
applied to a byte-oriented stream."

The "shall not" phrase means that doing so results in undefined
behaviour. An implementation can do what it likes in such cases. A
programmer should try to avoid them!

--
Ben.


原文链接: http://bytes.com/groups/c/852681-wprintf-conflicts-printf-glibc-bug


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值