🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2277

how do I typedef an array of pointers to a structure?

#2277
From: Timur Tabi
Date: Thu, 14 Mar 1996 02:26
40 lines
1857 bytes
I know this is a simple question, but I want to make sure that I get the
syntax absolutely correct.  I have a structure, called NODE_LINK:

class NODE;

typedef struct {
   unsigned uNumLinks;
   NODE *pnode[1];
} NODE_LINK;

The second field is supposed to be an array of pointers to NODE, which is an
undefined class (or a structure, it doesn't matter for this discussion). 
Question #1: did I define this field correctly?  How do I make sure that it's
not interpreted as a pointer to an array of NODE's?

Actually, the second field can be an array of any length, as long as it's at
least one element long.  In most cases, the array will end up being a few
elements long.

In addition, I want to have an array of pointers to NODE_LINK's.  What I have
right now is:

typedef NODE_LINK *NODE_LINK_PTR;

typedef NODE_LINK_PTR NODE_LINK_ARRAY[];

This breaks it down into two steps, but I want to avoid the intermediate step.
 Question #2: Does the following line produce the same definition for
NODE_LINK_ARRAY:

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?

--
Timur "too sexy for my code" Tabi, timur@vnet.ibm.com
Architect, OS/2 Warp realtime MIDI subsystem
http://timur.austin.ibm.com (internal IBM only)
http://www.shirenet.com/~crusader/Timur (external)
Technical Details
Message-ID: <4i804b$46u@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: timur@vnet.ibm.com (Timur Tabi)
Newsgroups: comp.lang.c.moderated
Subject: how do I typedef an array of pointers to a structure?
Date: 13 Mar 1996 20:26:19 -0600
Organization: IBM Austin
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4i804b$46u@solutions.solon.com>
Reply-To: timur@vnet.ibm.com
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: NeoLogic News for OS/2 [version: 4.5 YO Beta]