Date: Wed, 4 Sep 1996 22:58:59 -0300 Message-Id: <1.5.4.16.19960904200613.38df0bae@dmeasc.rc.ipt.br> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: "x DOT pons AT cc DOT uab DOT es" , djgpp AT delorie DOT com From: Cesar Scarpini Rabak Subject: Re: Declaring global arrays in a multisource project At 17:33 04/09/96 +0000, x DOT pons AT cc DOT uab DOT es wrote: >Dear programmers, > >In a multi-source project I have a global array, declared as: > > char my_global_array[256]; > >in one of the modules. > >Which is the best way of declaring it on the other modules? > > extern char my_global_array[256]; > extern char *my_global_array; > extern char my_global_array[]; > >Thanks, > >XP Of the three, the first and third are OK, the second is technically wrong. From a maintenance standpoint the third would easy your job if after a time you change your mind about the size of my_global_array in the module where it is defined (i,e. where memory is actually allocated for it). The third form is legal ANSI C because "the declaration is not a defining ocurrence" in ISO/ANSI C parlance. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cesar Scarpini Rabak E-mail: csrabak AT ipt DOT br DME/ASC Phone: 55-11-268-35221Ext.350 IPT - Instituto de Pesquisas Tecnologicas Fax: 55-11-268-5996 Av. Prof. Almeida Prado, 532. Sao Paulo - SP 05508-901 BRAZIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~