delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
X-Authentication-Warning: | argus.EECS.Berkeley.EDU: weimer owned process doing -bs |
Date: | Thu, 2 May 2002 14:41:24 -0700 (PDT) |
From: | Westley Weimer <weimer AT EECS DOT Berkeley DOT EDU> |
To: | cygwin AT cygwin DOT com |
cc: | weimer AT cs DOT berkeley DOT edu |
Subject: | Color Output with Printf |
Message-ID: | <Pine.SOL.4.44.0205021423370.23008-100000@argus.EECS.Berkeley.EDU> |
MIME-Version: | 1.0 |
A few weeks ago I asked if it was possible to build a binary with cygwin that does not required cygwin1.dll. I got back three different answers: (1) "try searching the mailing list archives for -mno-cygwin" (2) "You can't" (3) "Read the FAQ entry" Thanks to everyone who took the time to reply. It turns out that (1) worked for me (you can in fact build such a binary, under some contraints). Now I have a question about ANSI color. I have searched the archives and looked through the FAQ and I didn't find anything that answered this question. My apologies if it has already been discussed to death in some obvious location that slipped my mind :-). Consider the following program: int main() { printf("%c[1;31mHello\n",27); /* Prints "Hello\n" in RED (ANSI) */ return 0; } The problem is that it only works in some cases. Sometimes I see the escape codes echoed to the screen instead of seeing red text. Here are three compilation methods and two display environments (command and cmd behave identically): RXVT "cmd.exe" (dos prompt) gcc hello.c red red gcc hello.c -mno-cygwin red fails cl hello.c red fails Where "red" means that it works as expected (red text) and "fails" means that it didn't work (I saw the escape codes instead of them turning the text red). cl is the MS command-line C compiler, version 12.00.8804. RXVT is the version 2.7.2 (the one that came with cygwin for me, IIRC). Changing printf to fwrite or write has no effect. Putting flushes in there has no effect. Clearly it is possible to get red text in a dos prompt window: cygwin does it somehow. My personal theory is that the normal cygwin version is doing some special setup before main is called that causes stdout to be treated differently. I would like to get red text in a dos window without with either gcc -mno-cygwin or cl. Does anyone know how to do this? Does anyone know why "gcc" and "gcc -mno-cygwin" behave differently in this regard? Does anyone know what sort of setup things the cygwin version might be doing (so that I can manually copy them)? Thanks! - Wes -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |