Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!pyrltd!bjcong!emz From: emz@bjcong.bj.co.uk (ED ZIETARSKI) Newsgroups: comp.lang.c Subject: Re: extern Summary: Yes, it is an error to include array size in extern declaration Message-ID: <910@bjcong.bj.co.uk> Date: 28 Jun 90 14:01:31 GMT References: <111254@linus.mitre.org> Organization: Boldon James Limited (Congleton, UK) Lines: 23 In article <111254@linus.mitre.org>, cookson@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@bj.co.uk (UK only) emz@boldon-james-limited.co.uk (Internet) ..!mcsun!ukc!pyrltd!bjcong!emz