重定向stderr [英] Redirecting stderr

查看:98
本文介绍了重定向stderr的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用C编写的DLL写入stderr。我有一个win32

控制台应用程序,它调用DLL。在控制台应用程序中我使用freopen将stderr重定向到文件。
我遇到的问题是

,从DLL发送到stderr的消息都没有写入文件,但是如果我从控制台写入stderr

应用程序将其写入文件没问题。任何想法??

I have a DLL written in C that writes to stderr. I have a win32
console application that makes calls to the DLL. In the console app I
redirect stderr to a file using freopen. The problem I''m having is
that none of the messages sent to stderr from the DLL are getting
written to the file but if I write to stderr from the console
application it gets written to the file no problem. Any ideas??

推荐答案

2月27日晚上8:40,praetor.mich ... @ gmail.com ;

< praetor.mich ... @ gmail.comwrote:
On Feb 27, 8:40 pm, "praetor.mich...@gmail.com"
<praetor.mich...@gmail.comwrote:

我有一个用C编写的DLL写入stderr。我有一个win32

控制台应用程序,它调用DLL。在控制台应用程序中我使用freopen将stderr重定向到文件。
我遇到的问题是

,从DLL发送到stderr的消息都没有写入文件,但是如果我从控制台写入stderr

应用程序将其写入文件没问题。有任何想法吗??
I have a DLL written in C that writes to stderr. I have a win32
console application that makes calls to the DLL. In the console app I
redirect stderr to a file using freopen. The problem I''m having is
that none of the messages sent to stderr from the DLL are getting
written to the file but if I write to stderr from the console
application it gets written to the file no problem. Any ideas??



几个想法:


1)在适当的新闻组中询问。

2)图书馆函数不应该写入stderr

流。您应该考虑重新设计它们。

3)当您按照#1中给出的建议时,请给出

更多细节。


-

Bill Pursell


Several ideas:

1) Ask in an appropriate newsgroup.
2) Library functions should not write to the stderr
stream. You should consider redesigning them.
3) When you follow the advice given in #1, give
more details.

--
Bill Pursell


文章< 11 ************** *******@q2g2000cwa.googlegroups.c om>,
pr ** ***********@gmail.com < pr ************* @ gmail.comwrote:
In article <11*********************@q2g2000cwa.googlegroups.c om>,
pr*************@gmail.com <pr*************@gmail.comwrote:

>我有一个用C编写的DLL写入stderr。我有一个win32
控制台应用程序,可以调用DLL。在控制台应用程序中,我使用freopen将stderr重定向到文件。我遇到的问题是,从DLL发送到stderr的消息都没有写入文件但是如果我从控制台写入stderr
应用程序它会被写入到文件没问题。有任何想法吗??
>I have a DLL written in C that writes to stderr. I have a win32
console application that makes calls to the DLL. In the console app I
redirect stderr to a file using freopen. The problem I''m having is
that none of the messages sent to stderr from the DLL are getting
written to the file but if I write to stderr from the console
application it gets written to the file no problem. Any ideas??



这听起来像是一个更适合Windows

编程新闻组的问题。在这个新闻组comp.lang.c中,我们可以告诉你freopen()应该如何工作,但是与DLL之类的系统例程的交互

超出了C

语言本身的范围。


-

好​​的,只有流行语。两个音节,上衣。 - Laurie Anderson

That sounds like a question more appropriate for a Windows
programming newsgroup. In this newsgroup, comp.lang.c, we can
tell you about how freopen() is supposed to work, but interactions
with system routines such as DLLs are beyond the scope of the C
language itself.

--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson


2月27日下午4:02,rober ... @ ibd.nrc-cnrc.gc.ca(Walter Roberson)

写道:
On Feb 27, 4:02 pm, rober...@ibd.nrc-cnrc.gc.ca (Walter Roberson)
wrote:

文章< 1172608859.551149.90 ... @ q2g2000cwa.googlegroups.c om>,


praetor.mich ... @ gmail.com< praetor.mich ... @ gmail.comwrote:
In article <1172608859.551149.90...@q2g2000cwa.googlegroups.c om>,

praetor.mich...@gmail.com <praetor.mich...@gmail.comwrote:

我有一个用C编写的DLL写给斯特德尔。我有一个win32

控制台应用程序,它调用DLL。在控制台应用程序中我使用freopen将stderr重定向到文件。
我遇到的问题是

,从DLL发送到stderr的消息都没有写入文件,但是如果我从控制台写入stderr

应用程序将其写入文件没问题。有任何想法吗??
I have a DLL written in C that writes to stderr. I have a win32
console application that makes calls to the DLL. In the console app I
redirect stderr to a file using freopen. The problem I''m having is
that none of the messages sent to stderr from the DLL are getting
written to the file but if I write to stderr from the console
application it gets written to the file no problem. Any ideas??



这听起来像是一个更适合Windows

编程新闻组的问题。在这个新闻组comp.lang.c中,我们可以告诉你freopen()应该如何工作,但是与DLL之类的系统例程的交互

超出了C

语言本身的范围。


-

好​​的,只有流行语。两个音节,上衣。 - Laurie Anderson


That sounds like a question more appropriate for a Windows
programming newsgroup. In this newsgroup, comp.lang.c, we can
tell you about how freopen() is supposed to work, but interactions
with system routines such as DLLs are beyond the scope of the C
language itself.

--
Okay, buzzwords only. Two syllables, tops. -- Laurie Anderson



它在任何一个平台上实际上都是一样的。代码被设计为

来处理windows和所有unix风格。这就是我在这里发布的原因




至于库代码没有写到stderr你在哪里建议

错误信息被打印到??这就是Sterr

流的全部内容。


至于你的评论(比尔)更多细节,你还想要什么?

It actually works the same on either platforms. The code was designed
to work on windows and all unix flavors. Which is why I posted it
here.

As for the library code not writing to stderr where do you suggest an
error message get printed to?? That''s the whole point of the sterr
stream.

As for your comment (Bill) on more details, what more do you want??


这篇关于重定向stderr的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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