Connecting Tech Pros Worldwide Help | Site Map

Re: K&R Exercise 6-2

  #1  
Old August 29th, 2008, 03:55 PM
August Karlstrom
Guest
 
Posts: n/a
Richard Heathfield wrote:
[...]
Quote:
In C90, an implementation must be able to distinguish between external
identifiers that are unique in the first 6 characters (without regard to
case!). A program such as the one required in Exercise 6-2 could be useful
for diagnosing source code that ignores this limit (as I suspect a vast
amount of source code does).
So a library which exports e.g. the identifiers string_prepend and
string_append are not really C90 compliant?


August
  #2  
Old August 29th, 2008, 04:14 PM
Harald van =?UTF-8?b?RMSzaw==?=
Guest
 
Posts: n/a

re: Re: K&R Exercise 6-2


On Fri, 29 Aug 2008 16:51:56 +0200, August Karlstrom wrote:
Quote:
Richard Heathfield wrote:
[...]
Quote:
>In C90, an implementation must be able to distinguish between external
>identifiers that are unique in the first 6 characters (without regard
>to case!). A program such as the one required in Exercise 6-2 could be
>useful for diagnosing source code that ignores this limit (as I suspect
>a vast amount of source code does).
>
So a library which exports e.g. the identifiers string_prepend and
string_append are not really C90 compliant?
Correct. However, they are already not C90 compliant -- and not C99
compliant either -- for another reason: external identifiers starting with
str and followed by a lowercase letter are reserved for the implementation.
  #3  
Old August 29th, 2008, 04:14 PM
Richard Heathfield
Guest
 
Posts: n/a

re: Re: K&R Exercise 6-2


August Karlstrom said:
Quote:
Richard Heathfield wrote:
[...]
Quote:
>In C90, an implementation must be able to distinguish between external
>identifiers that are unique in the first 6 characters (without regard to
>case!). A program such as the one required in Exercise 6-2 could be
>useful for diagnosing source code that ignores this limit (as I suspect
>a vast amount of source code does).
>
So a library which exports e.g. the identifiers string_prepend and
string_append are not really C90 compliant?
Right, for two reasons:

(1) the names invade implementation namespace;
(2) the names are a touch on the long side.

In practice, (1) is often ignored, and (2) is practically always ignored.
But strictly speaking, yes, you are correct.

Of the two reasons, (1) is probably the more important. Whilst it is
certainly possible that some people are still using 6-sig-char linkers
nowadays, it isn't terribly likely that terribly many people are. Even
twenty years ago (and probably more), people were ignoring the 6-character
thing, and it doesn't seem to have caused any major software crises.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
  #4  
Old August 30th, 2008, 01:15 PM
August Karlstrom
Guest
 
Posts: n/a

re: Re: K&R Exercise 6-2


Harald van Dijk wrote:
Quote:
On Fri, 29 Aug 2008 16:51:56 +0200, August Karlstrom wrote:
Quote:
>Richard Heathfield wrote:
>[...]
Quote:
>>In C90, an implementation must be able to distinguish between external
>>identifiers that are unique in the first 6 characters (without regard
>>to case!). A program such as the one required in Exercise 6-2 could be
>>useful for diagnosing source code that ignores this limit (as I suspect
>>a vast amount of source code does).
>So a library which exports e.g. the identifiers string_prepend and
>string_append are not really C90 compliant?
>
Correct. However, they are already not C90 compliant -- and not C99
compliant either -- for another reason: external identifiers starting with
str and followed by a lowercase letter are reserved for the implementation.
Annoying. Is there a way to make a compiler like GCC emit a warning in
this case?


August
  #5  
Old August 30th, 2008, 01:15 PM
August Karlstrom
Guest
 
Posts: n/a

re: Re: K&R Exercise 6-2


Richard Heathfield wrote:
Quote:
August Karlstrom said:
Quote:
>So a library which exports e.g. the identifiers string_prepend and
>string_append are not really C90 compliant?
>
Right, for two reasons:
>
(1) the names invade implementation namespace;
(2) the names are a touch on the long side.
>
In practice, (1) is often ignored, and (2) is practically always ignored.
But strictly speaking, yes, you are correct.
>
Of the two reasons, (1) is probably the more important. Whilst it is
certainly possible that some people are still using 6-sig-char linkers
nowadays, it isn't terribly likely that terribly many people are. Even
twenty years ago (and probably more), people were ignoring the 6-character
thing, and it doesn't seem to have caused any major software crises.
Thanks for the clarification.


August
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Direct computation of integer limits in K&R2? santosh answers 88 March 18th, 2008 12:45 AM
&ensp in a monospaced font Andy Fish answers 59 March 5th, 2008 02:05 PM
Small Correction to K&R Exercise 1-22 Solution on CLC-Wiki Mike S answers 8 May 21st, 2006 07:46 AM
Which RegEx Testing Tool Do You Prefer? clintonG answers 17 November 19th, 2005 09:05 PM
K&R 1.5.1 exercise Merrill & Michele answers 12 November 14th, 2005 01:41 PM