[TUHS] The evolution of Unix facilities and architecture

Warner Losh imp at bsdimp.com
Fri May 12 08:06:45 AEST 2017


On Thu, May 11, 2017 at 3:44 PM, Dave Horsfall <dave at horsfall.org> wrote:
> On Thu, 11 May 2017, Michael Kjörling wrote:
>
>> On the flip side, it certainly does beat `char* x, y, z[100];` or `FILE*
>> fpsrc, fpdst;`. I wonder how many aspiring C programmers have been
>> tripped up by constructs like those? It's perfectly reasonable _once you
>> know about it_, but if you don't, then, well...
>
> Am I the only one here who thinks that e.g. a char pointer should be
> "char* cp1, cp2" instead of "char *cp1, *cp2"?  I.e. the fundamental type
> is "char*", not "char", and to this day I still write:
>
>     char*       cp1;
>     char*       cp2;
>
> etc, which IMHO makes it clear (which is every programmer's duty).  I used
> to write that way in a previous life, and the boss didn't complain.

I've encountered several people with that world view, so you aren't
alone. I take a contrary view. Since C doesn't behave that way, it
encourages people to think that char* cp1, cp2 is equivalent to what
you wrote, which it's not. * is a modifier of char rather than char *
being a fundamental type. Been burned too many times by it I guess
over the years.

Warner


More information about the TUHS mailing list