Re: Consideration on pointer declarations
- From: cri@xxxxxxxx (Richard Harter)
- Date: Thu, 05 Mar 2009 16:25:50 GMT
On Thu, 05 Mar 2009 12:10:18 +0000, Ben Bacarisse
<ben.usenet@xxxxxxxxx> wrote:
Starman <t.robelin@xxxxxxxxx> writes:
This is something I've pondered on for some years. The pointer symbol
* is tied to the variable, not to the type. So in all the code I've
seen so far I found:
char *pc;
I would say this the more common form (some people consider a third:
'char * pc;' by lets forget about that, yes?).
No, let's not. My preferred style is to line things up
vertically, one declaration per line, each line commented with a
description of the variable. (Quite often I'm not that fussy in
practice.) Here is an example (horizontal space trimmed for
posting).
DELIVERY {
AGENT_R agent_r; /* Agent receiving delivery */
PORT_NO port; /* Port receiving delivery */
size_t seqno; /* Expected inport serial number */
INPORT * inport; /* Pointer to agent inport struct */
};
This may seem anal rententive, but I have found that it is very
good practice, both for writing code and for reading it later.
Thus, your coding experience will be happier if every variable
has a clear, well defined meaning. Putting one declaration per
statement has the happy side effect of never missing one of those
asterisks.
Richard Harter, cri@xxxxxxxx
http://home.tiac.net/~cri, http://www.varinoma.com
Save the Earth now!!
It's the only planet with chocolate.
.
- Follow-Ups:
- Re: Consideration on pointer declarations
- From: Ben Bacarisse
- Re: Consideration on pointer declarations
- References:
- Consideration on pointer declarations
- From: Starman
- Re: Consideration on pointer declarations
- From: Ben Bacarisse
- Consideration on pointer declarations
- Prev by Date: Re: Question on finding the caller function.
- Next by Date: Re: Benefit of not defining the order of execution
- Previous by thread: Re: Consideration on pointer declarations
- Next by thread: Re: Consideration on pointer declarations
- Index(es):
Relevant Pages
|
Loading