From: Jeff Sullivan <jps@zk3.dec.com>
Subject: Re: Dec C pecularity
Date: 1999/06/22 [thread overview]
Message-ID: <376FD677.7E74690D@zk3.dec.com> (raw)
In-Reply-To: 87hfocxypx.fsf@romulus.bland.fido.de
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 <stdio.h>
> 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
next prev parent reply other threads:[~1999-06-22 4:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-06-09 4:00 Dec C pecularity Bernhard Reiter
1999-06-11 4:00 ` Jeff Sullivan
1999-06-13 4:00 ` Tobias Ernst
1999-06-14 4:00 ` Peter da Silva
1999-06-26 4:00 ` Tobias Ernst
1999-06-29 4:00 ` Charles M Richmond
1999-07-13 4:00 ` Tobias Ernst
1999-07-13 4:00 ` Charles M Richmond
1999-07-13 4:00 ` Kevin Oberman
1999-07-14 4:00 ` T.E.Dickey
1999-07-15 4:00 ` libcurses and patches for 4.0 jhitchcock
1999-07-16 4:00 ` T.E.Dickey
1999-08-10 4:00 ` b_andreasen
1999-07-16 4:00 ` Dec C pecularity Tobias Ernst
1999-07-18 4:00 ` T.E.Dickey
1999-07-14 4:00 ` T.E.Dickey
1999-06-22 4:00 ` Jeff Sullivan [this message]
1999-06-22 4:00 ` Jeff Sullivan
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox