Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | ralph <nt_consulting64@yahoo.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: macro conventions |
| Date | 2011-05-16 02:22 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ipg1t69sdqlusla40v1curmctr0lpgchu0@4ax.com> (permalink) |
| References | <4dcd62ab$0$23874$bbae4d71@news.suddenlink.net> <gjpqs69uh0h50ssjml2upma865bo90epav@4ax.com> <lnboz4gji9.fsf@nuthaus.mib.org> |
On Sun, 15 May 2011 06:50:54 -0700, Keith Thompson <kst-u@mib.org>
wrote:
>ralph <nt_consulting64@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.
Luckily most collisions are grievous enough to become quickly
identified during development. Real trouble often comes about, not
from using underscores per se, but from using certain keywords,
letters, or library tags as prefixes. For example, many years back I
remember a team getting tangled up with macros beginning with "E_",
"SIG_", "XL_", and "H_".
The problem in that case was not the few hours lost to development to
go back and clean it up. It was the endless ugliness that came about
because some pointed-hair boss decided that to avoid all future
collisions, all macros would be defined as ...
ABC_Co_FOO_BAR,
ABC_Co_Inventory_FOO_BAR,
ABC_Co_Errors_FOO_BAR,
ABC_Co_HeaderFile_FOO_BAR
...
Moral of the story: If you are working on a team and have a collision
- fix it AND keep your mouth shut. <bg>
-ralph
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
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
csiph-web