Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #105197

Re: Double-underline-itis

From Ben Bacarisse <ben.usenet@bsb.me.uk>
Newsgroups comp.lang.c
Subject Re: Double-underline-itis
Date 2017-03-01 01:19 +0000
Organization A noiseless patient Spider
Message-ID <87tw7doktz.fsf@bsb.me.uk> (permalink)
References <o951ti$ch6$1@dont-email.me>

Show all headers | View raw


BartC <bc@freeuk.com> writes:

> I came across this declaration in some Linux header:
>
>  extern int mbtowc (wchar_t *__restrict __pwc,
>           const char *__restrict __s, size_t __n) __THROW;
>
> There are thousands just the same. I can understand the
> double-underline prefix used for implementation names that may clash
> with those in the user namespace.
>
> But what's with the double-underline on the parameter names? They
> shouldn't clash with anything.

That's why the underscores are there.  Without them, the names could
clash with user-defined macros.

> (And here, I assumed __pwc was yet
> another attribute that the implementation thinks is needed.)

Why?  I would assume it's just the parameter name unless I had strong
evidence that it was not.

> Sometimes, as well as the double-underline at the start, they need to
> have one at the end too, such as '__restrict__' (what's wrong with
> just 'restrict', if you need to have it all?).

__restrict__ can be #defined away when processing the header with a
pre-1999 version of C.  You can't do that with restrict because it's not
a name reserved to the implementation.  Obviously one could use
different headers for different C versions, but this method is simple
and effective.

> Underlines are hard to see and tend to run together so you can't tell
> easily if there are two or three.

I don't have that problem.  _, __ and ___ all look very different to
me.  Maybe it's the font I use -- there is a slight gap between
consecutive underscores.

> Since $ isn't used much, what would have been wrong with that? It's
> not pretty but at least you can see it!

-- 
Ben.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Double-underline-itis BartC <bc@freeuk.com> - 2017-02-28 23:44 +0000
  Re: Double-underline-itis supercat@casperkitty.com - 2017-02-28 15:54 -0800
  Re: Double-underline-itis Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-01 01:19 +0000
    Re: Double-underline-itis David Brown <david.brown@hesbynett.no> - 2017-03-01 09:11 +0100
    Re: Double-underline-itis BartC <bc@freeuk.com> - 2017-03-01 11:45 +0000
      Re: Double-underline-itis Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-01 12:30 +0000
        Re: Double-underline-itis BartC <bc@freeuk.com> - 2017-03-01 13:04 +0000
          Re: Double-underline-itis Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-01 15:29 +0000
            Re: Double-underline-itis gazelle@shell.xmission.com (Kenny McCormack) - 2017-03-01 15:47 +0000
          Re: Double-underline-itis Keith Thompson <kst-u@mib.org> - 2017-03-01 09:30 -0800
            Re: Double-underline-itis supercat@casperkitty.com - 2017-03-01 10:14 -0800
            Re: Double-underline-itis Tim Rentsch <txr@alumni.caltech.edu> - 2017-04-16 18:45 -0700

csiph-web