Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #3906 > unrolled thread
| Started by | "Bill Cunningham" <nospam@nspam.invalid> |
|---|---|
| First post | 2011-05-13 12:56 -0400 |
| Last post | 2011-05-16 14:47 -0700 |
| Articles | 4 on this page of 24 — 15 participants |
Back to article view | Back to comp.lang.c
macro conventions "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-13 12:56 -0400
Re: macro conventions pete <pfiland@mindspring.com> - 2011-05-13 13:08 -0400
Re: macro conventions Shao Miller <sha0.miller@gmail.com> - 2011-05-13 13:14 -0400
Re: macro conventions Keith Thompson <kst-u@mib.org> - 2011-05-13 11:41 -0700
Re: macro conventions "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-14 23:08 -0400
Re: macro conventions ralph <nt_consulting64@yahoo.net> - 2011-05-13 13:15 -0500
Re: macro conventions "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-14 23:11 -0400
Re: macro conventions "Bill Cunningham" <nospam@nspam.invalid> - 2011-05-15 04:00 -0400
Re: macro conventions Angel <angel+news@spamcop.net> - 2011-05-15 11:15 +0000
Re: macro conventions Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-05-16 04:36 +0300
Re: macro conventions Ike Naar <ike@sverige.freeshell.org> - 2011-05-16 09:56 +0000
Re: macro conventions Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-05-16 19:00 +0300
Re: macro conventions Seebs <usenet-nospam@seebs.net> - 2011-05-16 19:10 +0000
Re: macro conventions Phil Carmody <thefatphil_demunged@yahoo.co.uk> - 2011-05-22 21:27 +0300
Re: macro conventions Keith Thompson <kst-u@mib.org> - 2011-05-15 06:50 -0700
Re: macro conventions Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-05-15 08:29 -0700
Re: macro conventions Ian Collins <ian-news@hotmail.com> - 2011-05-16 07:40 +1200
Re: macro conventions "osmium" <r124c4u102@comcast.net> - 2011-05-15 14:52 -0500
Re: macro conventions ralph <nt_consulting64@yahoo.net> - 2011-05-16 02:22 -0500
Re: macro conventions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-16 14:18 +0100
Re: macro conventions David Resnick <lndresnick@gmail.com> - 2011-05-16 08:03 -0700
Re: macro conventions Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-05-16 17:32 +0100
Re: macro conventions Keith Thompson <kst-u@mib.org> - 2011-05-16 08:43 -0700
Re: macro conventions Michael Press <rubrum@pacbell.net> - 2011-05-16 14:47 -0700
Page 2 of 2 — ← Prev page 1 [2]
| From | David Resnick <lndresnick@gmail.com> |
|---|---|
| Date | 2011-05-16 08:03 -0700 |
| Message-ID | <64c4e2c6-9d1f-4e23-be62-42d6511e8c83@u15g2000vby.googlegroups.com> |
| In reply to | #4067 |
On May 16, 9:18 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: > ralph <nt_consultin...@yahoo.net> writes: > > On Sun, 15 May 2011 06:50:54 -0700, Keith Thompson <ks...@mib.org> > > wrote: > > >>ralph <nt_consultin...@yahoo.net> writes: > >>[...] > >>> The actual 'rules' and conventions are more complicated and others > >>> will be along shortly to quote chapter and verse. However, in order to > >>> avoid collisions, best practice is simply never create a macro with an > >>> underscore for your own use and use always use uppercase. > > >>TO be clear, it's leading underscores that should be avoided. FOO_BAR, > >>for example, is perfectly ok. Trailing underscores are also ok, though > >>I wouldn't use them without a good reason. > > > Thanks for that catch. I did make it sound like underscores should be > > avoided throughout an identifier, when they are in fact OK. > > > It should also be amplified that double underscores "_ _" are reserved > > even within or trailing an identifier > > > FOO_BAR is OK, FOO__BAR or FOOBAR__ is not. > > What's your source? > > <snip> > -- > Ben. I'd guess his source is the C++ standard, where any identifier with __ is reserved. Yes, not generally relevant here, unless you want go keep your C header compatible with C++ for some reason. -David
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2011-05-16 17:32 +0100 |
| Message-ID | <0.b2cf055271007b7c9b97.20110516173205BST.8762pawqre.fsf@bsb.me.uk> |
| In reply to | #4072 |
David Resnick <lndresnick@gmail.com> writes: > On May 16, 9:18 am, Ben Bacarisse <ben.use...@bsb.me.uk> wrote: >> ralph <nt_consultin...@yahoo.net> writes: <snip> >> > It should also be amplified that double underscores "_ _" are reserved >> > even within or trailing an identifier >> >> > FOO_BAR is OK, FOO__BAR or FOOBAR__ is not. >> >> What's your source? <snip> > I'd guess his source is the C++ standard, where any identifier with __ > is reserved. Yes, not generally relevant here, unless you want go > keep your C header compatible with C++ for some reason. I'd say it is relevant here, but it would have helped to know it was "just in case" advice rather than the usual meaning of "reserved". -- Ben.
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2011-05-16 08:43 -0700 |
| Message-ID | <lniptafy7p.fsf@nuthaus.mib.org> |
| In reply to | #4055 |
ralph <nt_consulting64@yahoo.net> writes:
> On Sun, 15 May 2011 06:50:54 -0700, Keith Thompson <kst-u@mib.org>
> wrote:
[...]
>>TO be clear, it's leading underscores that should be avoided. FOO_BAR,
>>for example, is perfectly ok. Trailing underscores are also ok, though
>>I wouldn't use them without a good reason.
>
> Thanks for that catch. I did make it sound like underscores should be
> avoided throughout an identifier, when they are in fact OK.
>
> It should also be amplified that double underscores "_ _" are reserved
> even within or trailing an identifier
>
> FOO_BAR is OK, FOO__BAR or FOOBAR__ is not.
[...]
No, they aren't. I think C++ reserves idenifiers with double
underscores (so they can be used for name mangling, if I recall
correctly), but C doesn't.
Still, it certainly couldn't hurt to avoid double underscores in
C code.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
[toc] | [prev] | [next] | [standalone]
| From | Michael Press <rubrum@pacbell.net> |
|---|---|
| Date | 2011-05-16 14:47 -0700 |
| Message-ID | <rubrum-EB80E1.14473216052011@news.albasani.net> |
| In reply to | #4079 |
In article <lniptafy7p.fsf@nuthaus.mib.org>, Keith Thompson <kst-u@mib.org> wrote: > ralph <nt_consulting64@yahoo.net> writes: > > On Sun, 15 May 2011 06:50:54 -0700, Keith Thompson <kst-u@mib.org> > > wrote: > [...] > >>TO be clear, it's leading underscores that should be avoided. FOO_BAR, > >>for example, is perfectly ok. Trailing underscores are also ok, though > >>I wouldn't use them without a good reason. > > > > Thanks for that catch. I did make it sound like underscores should be > > avoided throughout an identifier, when they are in fact OK. > > > > It should also be amplified that double underscores "_ _" are reserved > > even within or trailing an identifier > > > > FOO_BAR is OK, FOO__BAR or FOOBAR__ is not. > [...] > > No, they aren't. I think C++ reserves idenifiers with double > underscores (so they can be used for name mangling, if I recall > correctly), but C doesn't. > > Still, it certainly couldn't hurt to avoid double underscores in > C code. Because every incursion on user name space is significant? -- Michael Press
[toc] | [prev] | [standalone]
Page 2 of 2 — ← Prev page 1 [2]
Back to top | Article view | comp.lang.c
csiph-web