From owner-freebsd-questions@FreeBSD.ORG Tue Jun 30 01:18:19 2009 Return-Path: Delivered-To: questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93B6E106564A for ; Tue, 30 Jun 2009 01:18:19 +0000 (UTC) (envelope-from bmettee@pchotshots.com) Received: from mail.pchotshots.com (ns1.pchotshots.com [12.172.123.235]) by mx1.freebsd.org (Postfix) with ESMTP id 110748FC12 for ; Tue, 30 Jun 2009 01:18:18 +0000 (UTC) (envelope-from bmettee@pchotshots.com) Received: (qmail 61847 invoked by uid 89); 30 Jun 2009 00:57:18 -0000 Received: from unknown (HELO dev2.pchotshots.com) (12.172.123.228) by mail.pchotshots.com with SMTP; 30 Jun 2009 00:57:18 -0000 Message-Id: <4.3.2.7.2.20090629204828.02ee3cb8@mail.pchotshots.com> X-Sender: bmettee@pchotshots.com@mail.pchotshots.com X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Date: Mon, 29 Jun 2009 20:51:37 -0400 To: Robert Huff ,questions@freebsd.org From: Brad Mettee In-Reply-To: <19017.24376.343126.389436@jerusalem.litteratus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Cc: Subject: Re: OT: C syntax question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2009 01:18:19 -0000 At 08:41 PM 6/29/2009, Robert Huff wrote: > Let us suppose I have a structure: > >struct CONTINENT { > ... >} > > I use this to create an array of pointers to said struct: > >struct CONTINENT *Asia[10][10]; > > Now I pass this array to a function: > > plate_shift(Asia, (int) foo, (float) bar); > > In the definition of the function, I say: > >int plate_shift(Cont,f,b) > struct CONTINENT *Cont[10][10]; > int f; > float b; >{ > ... >} > > and the compiler does not complain. If, however, I try to >prototype the function as: > > extern int plate_shift(struct CONTINENT *[][],int,float); > > with: > >CFLAGS = -Wall -std=c99 > > I get: > >error: array type has incomplete element type > > Changing to: > > extern int plate_shift(struct CONTINENT *foo[][],int,float); > > returns the same error. > K&R 2ed is not helpful, nor is a quick poke around the web. > What am I forgetting? > > Respectfully, > > > Robert Huff I believe since you are declaring the array as having a fixed number of elements, you must declare the function to take it the same way, like this: extern int plate_shift(struct CONTINENT *[10][10],int,float); Without the 10,10 size definition, the plate_shift function would have no idea how big the array of pointers actually is. Brad Mettee PC HotShots, Inc. Baltimore, MD (410) 426-7617 -> Let us bring out the *Power* of your PCs. <- -> Custom Business Software Solutions since 1991 <- visit http://www.pchotshots.com for information about our company.