MinGW: How do I temporarily disable stderr in a C(++) program

J

jacob navia

Richard said:
jacob navia said:
Richard Heathfield wrote:

[snip]
I think the situation was somewhat complicated by the mention of
Windows, since Windows might reasonably be regarded as what the
Standard calls a "freestanding implementation"; as such, it is not
required to provide support for stdin, stdout, and stderr, and AFAIK
it doesn't.
You are wrong. Windows provides support for stdin, stdout and stderr

Well, I didn't say it very well, did I? I apologise for expressing
myself poorly. Yes, if you're writing a console program, you can have
your stdin, stdout, and stderr. But I was in fact thinking specifically
of Win32 API programs, programs that actually use the Windowiness of
Windows. Now, it's entirely possible that Windows programs (of the
WinMain variety, so to speak) can take advantage of stdin/stdout/stderr
support, but I was under the impression that they cannot.

The only difference between windows and console programs is that
for console programs the system calls for you the API AllocConsole();
and you start in a "Dos" window. Within a console program you can use
the whole windows API, open windows, call any API function just as any
other windows program.

In the other hand, for "windows" programs, the system does NOT open
a console, and if you want to use stdin stderr and stdout you have to
call the API AllocConsole(). That is the ONLY difference.
 
R

Richard Heathfield

jacob navia said:

The only difference between windows and console programs is that
for console programs the system calls for you the API AllocConsole();
and you start in a "Dos" window. Within a console program you can use
the whole windows API, open windows, call any API function just as any
other windows program.

In the other hand, for "windows" programs, the system does NOT open
a console, and if you want to use stdin stderr and stdout you have to
call the API AllocConsole(). That is the ONLY difference.

Fine - so what you're saying is that stdin, stdout, and stderr are not
available to a Win32 GUI program unless the programmer sets them up
especially by calling a special function. Okay - I didn't know that.
(Because of the source of the information, which is well-known in
comp.lang.c to be unreliable, obviously I'll have to check it myself
before agreeing that it's correct.)
 
V

Vince C.

Flash said:
You were given good reasons. You were just very lucky that someone
eventually found out what your real requirements were, rather than what
you initially asked about, and happened to know something about the
functions in question. Had you asked in a GNU group as soon as you were
told that getopt etc were non-standard you would probably have got an
answer much faster, thus benefiting you.

Technical

When I posted the first time, I *really* believed that the heart of the
question was about stderr, which is C standard. Should I be blamed for
that? Also note my question was still usefull since I learnt I redirecting
stderr to a file is a one-way operation and there is no return. After all,
this is *exactly* what I wanted to know.

I just learnt the matter was off topic *after* I was asked what the context
was, of course. Had I known the stderr stuff was impossible, I wouldn't
even have bothered people asking any question here, of course.

Human

And my other point, which I felt forced to explain after being bashed the
first time, is maybe I was asking in the wrong forum (though I still doubt)
but there are several ways to tell somebody he's wrong, rude and non-rude.

I'm not objecting the technical reasons which tend to make my post
off-topic. I'm obecjting against the human nature of some of the responses.
I'm objecting against the way I was told.

I can cope with the technical reasons even if I disagree but I can't with
the rudeness of some of the people who "answered" - to be polite.

Sure I have to get a thicker skin but I find it so bad people are wasting
their skills with such humanly poor relations. We're all human being and
there are some who seem to have forgotten the definition.

Anyways I'll most probably won't post here ever again.
 
S

santosh

I can cope with the technical reasons even if I disagree but I can't with
the rudeness of some of the people who "answered" - to be polite.

Sure I have to get a thicker skin but I find it so bad people are wasting
their skills with such humanly poor relations. We're all human being and
there are some who seem to have forgotten the definition.

Anyways I'll most probably won't post here ever again.

Don't let the "rudeness" of a few people prevent you from
participating in this group. If you ever want to learn about C, this
is probably among the best places on the Net to do so. Yes, a handful
are perhaps a bit what you might call as "rude", but you can stop
reading their posts if you choose to. IMHO, almost all of the best
contributors to this group are very helpful.
 
J

Joe Wright

Vince said:
Technical

When I posted the first time, I *really* believed that the heart of the
question was about stderr, which is C standard. Should I be blamed for
that? Also note my question was still usefull since I learnt I redirecting
stderr to a file is a one-way operation and there is no return. After all,
this is *exactly* what I wanted to know.

I just learnt the matter was off topic *after* I was asked what the context
was, of course. Had I known the stderr stuff was impossible, I wouldn't
even have bothered people asking any question here, of course.

Human

And my other point, which I felt forced to explain after being bashed the
first time, is maybe I was asking in the wrong forum (though I still doubt)
but there are several ways to tell somebody he's wrong, rude and non-rude.

I'm not objecting the technical reasons which tend to make my post
off-topic. I'm obecjting against the human nature of some of the responses.
I'm objecting against the way I was told.

I can cope with the technical reasons even if I disagree but I can't with
the rudeness of some of the people who "answered" - to be polite.

Sure I have to get a thicker skin but I find it so bad people are wasting
their skills with such humanly poor relations. We're all human being and
there are some who seem to have forgotten the definition.

Anyways I'll most probably won't post here ever again.
You've chosen an excellent whine sir. Perhaps some cheese?
 
S

santosh

Joe said:
Vince C. wrote:
I'm not objecting the technical reasons which tend to make my post
off-topic. I'm obecjting against the human nature of some of the responses.
I'm objecting against the way I was told.

I can cope with the technical reasons even if I disagree but I can't with
the rudeness of some of the people who "answered" - to be polite.

Sure I have to get a thicker skin but I find it so bad people are wasting
their skills with such humanly poor relations. We're all human being and
there are some who seem to have forgotten the definition.

Anyways I'll most probably won't post here ever again.
You've chosen an excellent whine sir. [ ... ]

Made from sour grapes, I'm sure. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top