Article View: comp.lang.c.moderated
Article #2300Re: how do I typedef an array of pointers to a structure?
From: Henning Makholm
Date: Sat, 16 Mar 1996 14:50
Date: Sat, 16 Mar 1996 14:50
35 lines
1482 bytes
1482 bytes
timur@vnet.ibm.com (Timur Tabi) writes:
>typedef struct {
> unsigned uNumLinks;
> NODE *pnode[1];
>} NODE_LINK;
>Question #1: did I define this field correctly?
Yes, given that you really want your array to have length 1 :-)
>How do I make sure that it's not interpreted as a pointer to an array
>of NODE's?
By looking in a decent C grammar and discovering that postfixes bind
tighter than prefixes, in declarators as well as in expressions.
>typedef NODE_LINK *NODE_LINK_ARRAY[];
>
>How can I make sure that this isn't interpreted as a pointer to an array of
>NODE_LINK's?
The same way. If you want pointers to arrays you must use parantheses:
sometype (*id)[LENGTH] ;
If you feel unsecure either way it's always legal to clarify what you
mean using parantheses. I.e. for your array of pointers:
NODE *(pnode[1]);
--
Henning Makholm - math and CS student - University of Copenhagen
makholm@diku.dk - http://www.diku.dk/students/makholm - fido 2:235/224.92
Technical Details
Message-ID:
<4iekgg$9po@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i804b$46u@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: makholm@diku.dk (Henning Makholm) Newsgroups: comp.lang.c.moderated Subject: Re: how do I typedef an array of pointers to a structure? Date: 16 Mar 1996 08:50:56 -0600 Organization: Department of Computer Science, U of Copenhagen Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4iekgg$9po@solutions.solon.com> References: <4i804b$46u@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com