From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII X-Google-Thread: fee84,9a2a420ec841e44c X-Google-Attributes: gidfee84,public From: Jeff Sullivan Subject: Re: Dec C pecularity Date: 1999/06/22 Message-ID: <376FD677.7E74690D@zk3.dec.com>#1/1 X-Deja-AN: 492613850 Content-Transfer-Encoding: 8bit References: <37614C91.3FBFAB0A@zk3.dec.com> <87hfocxypx.fsf@romulus.bland.fido.de> X-Accept-Language: en Content-Type: text/plain; charset=iso-8859-1 Organization: Compaq Computer Corporation Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 Tobias Ernst wrote: > seeing that you really seem to care about removing Dec C peculiarities, there > is another one which has bothered me numerous times: > > #include > int main(void) > { > printf ("\x1B[2JThe screen is cleared.\n"); > return 0; > } In the program above, the difference is that \x escape sequences are not recognised in "common" (or "K&R") mode. If compiled in one of the ANSI modes: -std (Relaxed ANSI) or -std1 (Strict ANSI), you will see the "expected" result using DEC C (now Compaq C). > Gnu C can recognise "\x1B" as a way of encoding the character with > charactercode 0x1B (27, the escape character, here used to produce an > ANSI/VT100 sequence to clear the screen) into the string. Numerous other > compilers (esp. in the Dos/Windows world) also do. Dec C won�t, ... Yes, the difference here is that DEC C in UNIX V4.0x defaults to -std0 ("common" or "K&R") mode. Compilers in UNIX V5.0 and later, as well as our Developers' Toolkit compiler will default to -std. As such, you would get the "expected" results by default using any of the newer compilers. You can change your default locally by changing the "comp.config" file in /usr/lib/cmplrs/cc. This is described in the cc(1) man page. > and the problem is that Dec C does not even give a warning, so programs > that use it may fail very subtly at run time. You can enable a message for this by adding -w0, which tells the compiler to turn on informational messages. See below: % cc -std0 t.c -w0 cc: Info: t.c, line 6: An undefined escape sequence was encountered; the backslash is being ignored. (undefescap) printf ("\x1B[2JThe screen is cleared.\n"); --------------^ I hope this helps answer your questions. Feel free to let us know about other "peculiarities"! -Jeff -- Jeff Sullivan | Compaq Computer Corp | mailto:jps@zk3.dec.com Compaq C/C++ | Nashua, NH ZK3-2X23 | Jeff.Sullivan@compaq.com