带逗号的意外流输出 [英] unexpected stream output with commas

查看:52
本文介绍了带逗号的意外流输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里发生了一个奇怪的错误...


//这里正确包含和附加代码

int x = 2552123;

cout<< x;


结果输出如下:2,552,123

与stringstreams相同的行为。


怎么能这样正在发生什么?

这并不总是发生......似乎只有当我们用一些共享库(.so)创建我们的可执行文件

时才会发生。 />
它在main()中正常工作,但在我们的类源文件中没有。

当链接静态库(.a)时,它按预期工作。


如果重要的话,我们正在使用Visual Age 6.0在AIX上进行开发。


这可能与我们的共享错误有关

图书馆......关于可能造成这种情况的任何提示?


谢谢,

凯尔

解决方案



" Kyle Kolander" < KK ******* @ hotmail.com>在消息中写道

新闻:JZ *********** @ dfw-service2.ext.ray.com ...

有个奇怪的bug继续在这里...

//正确包含和其他代码在这里
int x = 2552123;
cout<< x;

这导致输出如下:2,552,123


我认为你不想要逗号?或者你想要时间吗? (你

没有具体说明你的实际预期。)

与stringstreams相同的行为。

怎么会发生这种情况?
这并不总是发生......似乎只有当我们使用我们的一些共享库(.so)创建我们的
可执行文件时才会发生。
它在工作时正常工作main()但不是在我们的类源文件中。
当链接静态库(.a)时,它按预期工作。

我们正在使用Visual Age 6.0在AIX上进行开发。

这可能与我们共享的库有不正确的关系......任何可能导致这种情况的提示?

谢谢,
Kyle


我猜想共享库正在指定语言环境信息,并且

包括是否使用数千个分隔符(以及如何使用

为他们)。检查共享库代码(以及用于构建

的设置,或许?),看看他们是否正在制作这样的规范。如果没有,

那么也许你需要添加代码告诉他们不要使用分隔符?

我不熟悉如何做这些事情,但是这个至少应该帮助你指出正确的方向
。谷歌搜索可能会有所帮助。


-Howard



Kyle Kolander写道:

这里有一个奇怪的错误...

//正确包含和其他代码在这里
int x = 2552123;
cout << x;

这导致输出如下:2,552,123
与stringstreams相同的行为。

这怎么可能发生?
这不是总是发生...似乎只有当我们使用我们的一些共享库(.so)创建我们的可执行文件时才会发生。
它在main()中正常工作,但在我们的类源文件中却不正常。当与静态库(.a)链接时,它按预期工作。

如果重要的话,我们正在使用Visual Age 6.0在AIX上进行开发。

它是可能是我们在共享的库中做错了什么...有什么可能导致这个问题的提示?




默认语言环境设置使用''do_grouping ''导致''thousands_sep''

字符被插入到输出中。我对这些东西不太了解,但一般都会读到有关语言环境的内容。可能是你的代码使用

加载某个.so的不同语言环境。它必须将区域设置

设置为某种东西而不是保持不变。阅读该库的文档

,特别是它描述语言环境的部分。


V


Victor Bazarov <五******** @ comAcast.net>在消息中写道

新闻:W4 ******************* @ newsread1.mlpsca01.us.t o.verio.net ... < blockquote class =post_quotes> Kyle Kolander写道:

这里有一个奇怪的错误...

//正确包含和其他代码在这里
int x = 2552123;
cout<< x;

这导致输出如下:2,552,123
与stringstreams相同的行为。

这怎么可能发生?
这不是总是发生...似乎只有当我们使用我们的一些共享库(.so)创建
可执行文件时。
它在main()中正常工作,但在我们的类源中不能正常工作
文件。当与静态库(.a)链接时,它按预期工作。

如果重要的话,我们正在使用Visual Age 6.0在AIX上进行开发。

这可能是我们的事情对我们的共享库做错了...有什么可能导致这个问题的提示?



默认语言环境设置使用''do_grouping''导致''thousands_sep ''
要插入输出的字符。我对这些事情一无所知,但一般都会阅读有关语言环境的内容。如果加载某个.so,可能是你的代码使用了不同的语言环境。它必须将语言环境设置为某种东西而不是保持不变。阅读该库的文档
,特别是它描述语言环境的部分。

V




谢谢大家......我在快速搜索谷歌之后开始怀疑地区是问题。

我也只阅读了一些关于语言环境设置并且从未使用过它们。

我会查看你的建议。


再次感谢,

Kyle


Got a strange bug going on here...

// proper includes and additional code here
int x = 2552123;
cout << x;

This results in output like this: 2,552,123
Same behavior with stringstreams.

How can this be happening?
This doesn''t always happen... seems like only when we create our executable
with some of our shared libraries (.so).
It works correctly when in main() but not when in our class source files.
When linking with static libraries (.a) it works as expected.

We are developing on AIX with Visual Age 6.0 if that matters.

It''s probably something we are doing incorrectly with our shared
libraries... any hints as to what could be causing this?

Thanks,
Kyle

解决方案


"Kyle Kolander" <kk*******@hotmail.com> wrote in message
news:JZ***********@dfw-service2.ext.ray.com...

Got a strange bug going on here...

// proper includes and additional code here
int x = 2552123;
cout << x;

This results in output like this: 2,552,123
I take it you don''t want the commas? Or do you want periods there? (You
don''t specify what it is you actually expected.)
Same behavior with stringstreams.

How can this be happening?
This doesn''t always happen... seems like only when we create our
executable
with some of our shared libraries (.so).
It works correctly when in main() but not when in our class source files.
When linking with static libraries (.a) it works as expected.

We are developing on AIX with Visual Age 6.0 if that matters.

It''s probably something we are doing incorrectly with our shared
libraries... any hints as to what could be causing this?

Thanks,
Kyle

I''d guess that the shared libraries are specifying locale information, and
that includes whether or not to use thousands separators (and what to use
for them). Check the shared library code (and the settings used to build
them, perhaps?), and see if they''re making such specifications. If not,
then perhaps you need to add code to tell them to NOT use the separators?
I''m not familiar with how to do such things, but this should help point you
in the right direction, at least. A Google search might help more.

-Howard



Kyle Kolander wrote:

Got a strange bug going on here...

// proper includes and additional code here
int x = 2552123;
cout << x;

This results in output like this: 2,552,123
Same behavior with stringstreams.

How can this be happening?
This doesn''t always happen... seems like only when we create our executable
with some of our shared libraries (.so).
It works correctly when in main() but not when in our class source files.
When linking with static libraries (.a) it works as expected.

We are developing on AIX with Visual Age 6.0 if that matters.

It''s probably something we are doing incorrectly with our shared
libraries... any hints as to what could be causing this?



Default locale setting uses ''do_grouping'' that causes ''thousands_sep''
character to be inserted into the output. I don''t know much about those
things, but read about locales in general. Could it be your code uses
different locales if a certain .so is loaded. It must set the locale
to something instead of just leaving it unchanged. Read the documentation
for that library, especially the part where it describes locales.

V


"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:W4*******************@newsread1.mlpsca01.us.t o.verio.net...

Kyle Kolander wrote:

Got a strange bug going on here...

// proper includes and additional code here
int x = 2552123;
cout << x;

This results in output like this: 2,552,123
Same behavior with stringstreams.

How can this be happening?
This doesn''t always happen... seems like only when we create our executable with some of our shared libraries (.so).
It works correctly when in main() but not when in our class source files. When linking with static libraries (.a) it works as expected.

We are developing on AIX with Visual Age 6.0 if that matters.

It''s probably something we are doing incorrectly with our shared
libraries... any hints as to what could be causing this?



Default locale setting uses ''do_grouping'' that causes ''thousands_sep''
character to be inserted into the output. I don''t know much about those
things, but read about locales in general. Could it be your code uses
different locales if a certain .so is loaded. It must set the locale
to something instead of just leaving it unchanged. Read the documentation
for that library, especially the part where it describes locales.

V



Thanks guys... I started suspecting locale was the problem after a quick
search of google.
I have also only read a bit about locale settings and never used them.
I''ll look into your suggestions.

Thanks again,
Kyle


这篇关于带逗号的意外流输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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