Mail Archives: djgpp/1996/09/05/10:15:45
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Raw text -