extern

ED ZIETARSKI emz at bjcong.bj.co.uk
Fri Jun 29 00:01:31 AEST 1990


In article <111254 at linus.mitre.org>, cookson at helios.mitre.org (Dean Cookson) writes:
> I know that if you have an extern that is an array, you don't have to use
> the size of the array in the extern declaration, you only need it in
> the original declaration.  But is it an error to include it in the
> extern declaration??
> 
> ie:
> file1.c
> int	myarray[10];
> 
> file2.c
> extern int	myarray[10];
I would say it is an error because if you or someone else changes the array size
at a later stage, (s)he would have to also know/remember that the external
declaration needs changing. Even if you use a #define for the array size, you
could still have the situation arising of someone deciding to use a *different*
preprocessor definition name. The compiler cannot pick up differences in array
sizes in a set of objects and neither can the linker (as far as I know !)
---
Ed Zietarski, Boldon James Limited, Congleton, CHESHIRE CW12 1JN, UK.
emz at bj.co.uk (UK only)
emz at boldon-james-limited.co.uk (Internet)
..!mcsun!ukc!pyrltd!bjcong!emz



More information about the Comp.lang.c mailing list