🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.bugs
Article #2171

Re: sc 6.1 - Allow ANSI pre-processor and read-only strings

#2171
From: Tom Tkacik
Date: Wed, 05 Apr 1989 19:49
50 lines
2792 bytes
In article <13774@sequent.UUCP> rgb@sequent.UUCP (Bob Bond) writes:
>With regards to the SC 6.1 release:
>From article <137@titania.warwick.ac.uk>, by cudcv@warwick.ac.uk (Rob McMahon):
>> The first [problem] is the ctl macro relies on a non-ANSI
>> pre-processor which will do replacement of macro arguments within
>> strings, this will stop it compiling at all.
>
>This release has been interesting from this perspective.  The ctl()
>macro has been "shipping" like this for 3+ years and I have never had a
>complaint before now.  I have received at least 5 separate complaints
>since the 6.1 release last month.  I draw a couple of conclusions - gcc
>is a real force in the market and ANSI is breaking some things they
>should have standarized.

Or at least GCC is making people aware of the differences between
K&R C and ANSI C.  They show up more frequently than most people believe.
I do not think that ANSI is breaking things they should have standardized,
but that perhaps there were some bad (less than desirable:-)) coding
practices that have become standard because early compilers (and preprocessors)
allowed them.  It is a good idea to try and break these practices
rather than formally standardize them.

>
>> The second is that it tries to write to strings constants, which may be
>> in read-only memory, so that it dumps core as soon as you try to run it.
>
>Who said compilers could put strings somewhere other than data space?  :-)

The pANS says that string constants can be put in text space.
I believe that this was so that strings constants could be shared, and that
they could also be put in ROM.  Current K&R C does not allow this.

To compile SC 6.1 with gcc use
   gcc -traditional -fwritable-strings

These are the two most common cases of pANS C being different from K&R C.

It seems that ANSI C is getting close enough that old code should be looked
at to see if it can be made to conform to both.
For example, the ctl() macro should be made to take its argument already a
character literal, (ie.  ctl('x') instead of ctl(x) ).
This will work with both K&R and ANSI C.

Other differences are not so easy, like string concatenation which is done
in incompatable ways.  But that which can be made to conform should.

---
Tom Tkacik
GM Research Labs,   Warren MI  48090
uunet!edsews!rphroy!megatron!tkacik
Technical Details
Message-ID: <10727@rphroy.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!edsews!rphroy!tkacik
References: <137@titania.warwick.ac.uk> <13774@sequent.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!edsews!rphroy!tkacik
From: tkacik@rphroy.UUCP (Tom Tkacik)
Newsgroups: comp.sources.bugs
Subject: Re: sc 6.1 - Allow ANSI pre-processor and read-only strings
Message-ID: <10727@rphroy.UUCP>
Date: 5 Apr 89 19:49:25 GMT
References: <137@titania.warwick.ac.uk> <13774@sequent.UUCP>
Reply-To: tkacik@rphroy.UUCP (Tom Tkacik)
Organization: GM Research Labs, Warren, MI
Lines: 50