Subject: Re: __UNCONST(a)
To: NetBSD Userlevel Technical Discussion List <tech-userlevel@NetBSD.ORG>
From: Roland C. Dowdeswell <>
List: tech-userlevel
Date: 07/02/2004 15:03:20
On 1088793800 seconds since the Beginning of the UNIX epoch
"Greg A. Woods" wrote:

>OK, it's one thing that we have standards specified APIs that are
>"difficult" to implement in strict Standard C without stripping "const"
>qualifiers, but it would seem unnecessary (to the point of being a very
>bad practice) for an application author to design an API that also
>required similar hacks in order to be implemented "quietly".

How exactly do you return an element of an array while promising
that you are not going to modify it then?  You can't return a const
foo * because then the caller may be calling with an array that
they would like to be able to modify.  If you do not promise to
not modify the array then the caller may have to deconst something
that has been passed to them as a const.  strchr(3) is an instance
of this issue.

    Roland Dowdeswell                      http://www.Imrryr.ORG/~elric/