printf中的'flag中的可移植性问题 [英] portability issues with ' flag in printf

查看:86
本文介绍了printf中的'flag中的可移植性问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

* printf中的''(单引号/撇号 - ASCII 0x27)标志(

导致按照语言环境定义整数组)不在
$ b $中b C标准,并且应用于浮子甚至不在SUSv2中。另一方面,它是非常有用的。我想知道人们如何检查

支持它的printf版本的可用性。我在autoconf宏库中找不到一个

宏,我很难写出我自己的b $ b因为所有的系统都是我有轻松访问使用

版本的gcc支持它所以我不知道什么是失败模式

在没有的系统上。别人怎么处理这个?有没有我不知道的

autoconf宏?或者使用不支持它的编译器

的人可以告诉我它是否在编译时产生语法错误或运行时错误?谢谢。

The '' (single quote/apostrophe - ASCII 0x27) flag in *printf (which
causes delimitation of integer groups as per the locale) is not in the
C standard, and as applied to floats is not even in SUSv2. On the other
hand, it is very useful. I''m wondering how people check for
availability of a version of printf that supports it. I don''t find a
macro for this in the autoconf macro library, and I''m hard put to write
my own because all of the systems to which I have easy access use
versions of gcc that support it so I don''t know what the failure mode
is on systems that do not. How do other people handle this? Is there an
autoconf macro I don''t know about? Or can someone who uses a compiler
that doesn''t support it tell me whether it generates a syntax error at
compile time or a runtime error? Thanks.

推荐答案

bi*******@alum.mit.edu kirjoitti:
bi*******@alum.mit.edu kirjoitti:
* printf中的''(单引号/撇号 - ASCII 0x27)标志(
导致整数组的定界(根据语言环境)不在
C标准中,并且应用于浮点数甚至不在SUSv2中。另一方面,它非常有用。我想知道人们如何检查支持它的printf版本的可用性。我在autoconf宏库中找不到这个宏,我很难写自己的,因为我可以轻松访问的所有系统都使用
支持它的gcc版本,所以我不知道故障模式是什么,而不是系统。别人怎么处理这个?有没有我不知道的
autoconf宏?或者使用不支持它的编译器的人可以告诉我它是否在编译时生成语法错误或运行时错误?谢谢。
The '' (single quote/apostrophe - ASCII 0x27) flag in *printf (which
causes delimitation of integer groups as per the locale) is not in the
C standard, and as applied to floats is not even in SUSv2. On the other
hand, it is very useful. I''m wondering how people check for
availability of a version of printf that supports it. I don''t find a
macro for this in the autoconf macro library, and I''m hard put to write
my own because all of the systems to which I have easy access use
versions of gcc that support it so I don''t know what the failure mode
is on systems that do not. How do other people handle this? Is there an
autoconf macro I don''t know about? Or can someone who uses a compiler
that doesn''t support it tell me whether it generates a syntax error at
compile time or a runtime error? Thanks.




编写自己的测试,参见
手册的_blank> http://www.gnu.org/software/autoconf
。这真的不像你想象的那么难。


Aki Tuomi



Write your own test, see http://www.gnu.org/software/autoconf for
manual. It really isn''t as hard as you might think.

Aki Tuomi


bi ******* @ alum.mit.edu 认为:
bi*******@alum.mit.edu opined:
'' * printf中的(单引号/撇号 - ASCII 0x27)标志(
导致整数组按照语言环境划分)不在C标准中,并且应用于浮点数甚至不在SUSv2中。


这会让它偏离主题。

另一方面,它非常有用。我想知道人们如何检查
是否支持它的printf版本。


通过阅读他们特定实现的文档?

我在autoconf宏库中找不到这个宏,我是
很难写出我自己的,因为我所拥有的所有系统都很容易访问使用支持它的gcc版本所以我不知道什么是故障模式在系统上那不。其他人如何处理这个?有没有我不知道的autoconf宏?


所有偏离此处的主题。

或者使用不支持它的编译器的人可以告诉我
它是否生成了在编译时或运行时出现语法错误
错误?
The '' (single quote/apostrophe - ASCII 0x27) flag in *printf (which
causes delimitation of integer groups as per the locale) is not in
the C standard, and as applied to floats is not even in SUSv2.
That''d make it off-topic here.
On the other hand, it is very useful. I''m wondering how people check
for availability of a version of printf that supports it.
By reading the documentation of their particular implementation?
I don''t find a macro for this in the autoconf macro library, and I''m
hard put to write my own because all of the systems to which I have
easy access use versions of gcc that support it so I don''t know what
the failure mode is on systems that do not. How do other people
handle this? Is there an autoconf macro I don''t know about?
All off-topic here.
Or can someone who uses a compiler that doesn''t support it tell me
whether it generates a syntax error at compile time or a runtime
error?




据推测,使用不支持此实现的实现的人(或者从来没有支持
)有用的,就像我的情况一样),不熟悉

正确的语法来检查你并告诉结果。


考虑使用此方法发布合法的`printf()`调用。也许有人会把它试试出去告诉你他们得到了什么。


-

是[Linux用户] lemmings集体跳下悬崖

可靠,精心设计的商业软件?

(由Matt Welsh提供)


< http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>



Presumably, people using implementations not supporting this (or who
never had use for it, as is my case), won''t be familiar with the
correct syntax to check for you and tell the results.

Consider posting a legal `printf()` call using this. Maybe someone will
try it out and tell you what they got.

--
"Are [Linux users] lemmings collectively jumping off of the cliff of
reliable, well-engineered commercial software?"
(By Matt Welsh)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>


bi ******* @ alum.mit.edu écrit:
''(单引号/撇号 - * printf中的ASCII 0x27)标志(
导致按照语言环境定义整数组)不在
C标准中,并且应用于浮点数甚至不在SUSv2中。另一方面,它非常有用。我想知道人们如何检查支持它的printf版本的可用性。我在autoconf宏库中找不到这个宏,我很难写自己的,因为我可以轻松访问的所有系统都使用
支持它的gcc版本,所以我不知道故障模式是什么,而不是系统。别人怎么处理这个?有没有我不知道的
autoconf宏?或者使用不支持它的编译器的人可以告诉我它是否在编译时生成语法错误或运行时错误?谢谢。
The '' (single quote/apostrophe - ASCII 0x27) flag in *printf (which
causes delimitation of integer groups as per the locale) is not in the
C standard, and as applied to floats is not even in SUSv2. On the other
hand, it is very useful. I''m wondering how people check for
availability of a version of printf that supports it. I don''t find a
macro for this in the autoconf macro library, and I''m hard put to write
my own because all of the systems to which I have easy access use
versions of gcc that support it so I don''t know what the failure mode
is on systems that do not. How do other people handle this? Is there an
autoconf macro I don''t know about? Or can someone who uses a compiler
that doesn''t support it tell me whether it generates a syntax error at
compile time or a runtime error? Thanks.



#include< stdio.h>

#include< string.h>

int main(void )

{

int ll = 87334455;

char buf [256];


sprintf (buf,"%''d \ n",ll);

if(strchr(buf,''\''''))

printf (此编译器不支持''限定符\ nn;)

else

printf("此编译器支持''限定符\ nn" );


}


使用Microsoft CL我获得

此编译器不支持''限定符

使用lcc-win32我获得

这个编译器支持''限定符

使用gcc我获得

这个编译器支持''限定符

jacob


#include <stdio.h>
#include <string.h>
int main(void)
{
int ll = 87334455;
char buf[256];

sprintf(buf,"%''d\n",ll);
if (strchr(buf,''\''''))
printf("This compiler does NOT support the '' qualifier\n");
else
printf("This compiler supports the '' qualifier\n");

}

Using Microsoft CL I obtain
This compiler does NOT support the '' qualifier
Using lcc-win32 I obtain
This compiler supports the '' qualifier
Using gcc I obtain
This compiler supports the '' qualifier
jacob


这篇关于printf中的'flag中的可移植性问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆