Re: Nit pick -- where to stick the * in a C/C++ definition

Subject: Re: Nit pick -- where to stick the * in a C/C++ definition
From: Chris Gooch <Chris -at- lightwork -dot- co -dot- uk>
To: "TECHWR-L" <techwr-l -at- lists -dot- raycomm -dot- com>
Date: Fri, 2 Mar 2001 11:42:34 -0000

Haas wrote:

> I am documenting an API in C++. I need to decide on a
> standard representation for pointer definitions.
> C and C++ themselves don't care whether I say:
> int * foo //centered
> int* foo //closed left
> or int *foo //closed right

I (think) I prefer the `closed right' method. It
seems a bit neater, and possibly less error prone
since as you point out

int* foo, bar;

may be misread. Same goes for [] and **, ***, **[],

A related point being that when a variable is
being cast from one type to another, to be consistent
it needs to be written as

(char *)foo = c;

Having said that, a quick check through my docs and
I've mostly used the closed right hand method, but(!)
aaarrgghhhh there are a couple of instances where the
left hand method is used! Damn. Now I have work to do,

Check whether your company has any written coding
standards which are meant to be followed. Ours say
that right closed form should be used, but sometimes
developers forget (especially newbies) or disagree
(especially oldbies).


Christopher Gooch, Technical Author,
LightWork Design Ltd., Sheffield, England.

chris -at- lightwork -dot- co -dot- uk

Develop HTML-Based Help with Macromedia Dreamweaver 4 ($100 STC Discount)
**WEST COAST LOCATIONS** San Jose (Mar 1-2), San Francisco (Apr 16-17) or 800-646-9989.

Sponsored by ForeFront, Inc., maker of ForeHelp Help authoring tools
for print, WinHelp, HTML Help, JavaHelp, and cross-platform InterHelp
See for more information and free evaluation downloads

You are currently subscribed to techwr-l as: archive -at- raycomm -dot- com
To unsubscribe send a blank email to leave-techwr-l-obscured -at- lists -dot- raycomm -dot- com
Send administrative questions to ejray -at- raycomm -dot- com -dot- Visit for more resources and info.

Previous by Author: Re: Open Source Project Management Tool
Next by Author: RE: Taking Minutes at Meetings
Previous by Thread: Nit pick -- where to stick the * in a C/C++ definition
Next by Thread: RE: Nit pick -- where to stick the * in a C/C++ definition

What this post helpful? Share it with friends and colleagues:

Sponsored Ads