tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: constify dirname/basename [was: CVS commit: src]



David Holland wrote:-

> On Thu, Apr 24, 2008 at 08:03:30AM +0900, Neil Booth wrote:
>  > > > SUSv3 says that both functions "may modify the string pointed to by
>  > > > path" (the argument to those functions).  While our implementations
>  > > > don't do that, are we OK by the standards to now declare those
>  > > > functions as having a const argument?
>  > > 
>  > > I can't see why not.
>  > 
>  > It means user-space code redeclaring the function will now get
>  > an incompatible redclaration error.
>  > 
>  > From my understanding we cannot do this whilst retaining conformance
>  > to a spec; the prototype has to be compatible.
> 
> Whether or not standards technically allow it, user code should never
> do that.

Indeed, C99 Example 7.1.4p5 that explicitly lists such a construct
as an example of how to use standard library functions was clearly
mistaken, then.  Perhaps you should tell the C committee they didn't
know what they were doing when they wrote that.

It's quite clear to someone serious about implementing the language
standards that what has been done here is incorrect standards.
It's quite a different thing to agree whether it's a good idea or
not.

Neil.


Home | Main Index | Thread Index | Old Index