9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Dan Cross <cross@math.psu.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] thread
Date: Thu,  5 Jul 2001 22:05:12 -0400	[thread overview]
Message-ID: <200107060205.WAA21989@augusta.math.psu.edu> (raw)
In-Reply-To: <20010706010009.D94AF199C0@mail.cse.psu.edu>

In article <20010706010009.D94AF199C0@mail.cse.psu.edu> you write:
>Hello 9fans,

Hey Kenji,

>Manual of thread shows the example codes such as:
>	char m[48];
>	...
>	{nil,   &m,     CHANRCV},
>I wonder that &m is a typo.

No, &m in this context is perfectly legal C.  ``&'' in C says
to take the address of the referenced object (m), where m refers
to that 48 char array.  However, ``m'' by itself will also decay
into a pointer to the array, so the two uses are equivalent in
this context.  At least, that's the gist of it; Doug Gywn would
be able to describe it more precisely than I have.

As Rob says, though, the & is irrelevant, and I've seen it be
confusing in the past; particularly for junior programmers.  I
recommend writing C code which references arrays without the &.

	- Dan C.



  reply	other threads:[~2001-07-06  2:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-06  0:50 arisawa
2001-07-06  2:05 ` Dan Cross [this message]
2001-07-06  1:02 rob pike
2001-07-06  4:15 arisawa
2001-07-06 14:41 ` Dan Cross
2001-07-06 18:24   ` Boyd Roberts
2001-07-06  5:55 dmr
2001-07-06 16:54 ` Digby Tarvin
2001-07-09  8:33   ` Douglas A. Gwyn
2001-07-09 11:46     ` Digby Tarvin
2001-07-09 17:03       ` Dan Cross
2001-07-09 11:49     ` Boyd Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200107060205.WAA21989@augusta.math.psu.edu \
    --to=cross@math.psu.edu \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).