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

Tom Tkacik tkacik at rphroy.UUCP
Thu Apr 6 05:49:25 AEST 1989


In article <13774 at sequent.UUCP> rgb at sequent.UUCP (Bob Bond) writes:
>With regards to the SC 6.1 release:
>From article <137 at titania.warwick.ac.uk>, by cudcv at 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



More information about the Comp.sources.bugs mailing list