[Info-vax] Possible C compiler static variable initialization problem.
johnwallace4 at yahoo.co.uk
johnwallace4 at yahoo.co.uk
Wed Feb 26 14:17:14 EST 2014
On Wednesday, 26 February 2014 18:40:54 UTC, Simon Clubley wrote:
> On 2014-02-26, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> wrote:
>
> > On 2014-02-26, Bob Koehler <koehler at eisner.nospam.encompasserve.org> wrote:
>
> >> In article <leko68$egf$1 at dont-email.me>, Simon Clubley <clubley at remove_me.eisner.decus.org-Earth.UFP> writes:
>
> >>>
>
> >>> On VMS, variables defined in different source files, but with the same name,
>
> >>> were traditionally treated as different variables by the linker and space
>
> >>> allocated for each variable definition.
>
> >>
>
> >> I've been working with C on VMS since early VAX C days, and I've
>
> >> never seen that. A file level variable (outside of any function)
>
> >> is treats as global to the code unless it's specificially declared
>
> >> static.
>
> >>
>
> >
>
> > My apologies for the wrong information than.
>
> >
>
> > I encountered this back in the 90s with a C compiler and I had thought it
>
> > was on VMS. I wonder if it was one of the early Microsoft C MS-DOS/Win 9x
>
> > compilers which I worked with in that timeframe as well ?
>
> >
>
>
>
> I'm now really curious about this now I think I've remembered a bit more.
>
> IIRC, on the C compiler in question you only had one declaration allowed
>
> for a variable at file level and all the other file level declarations
>
> in other source files _had_ to be extern references to the first
>
> declaration.
>
>
>
> After thinking about it a bit more, I cannot be sure anymore, if you tried
>
> to define the variable twice at file level in different source files, if
>
> the linker wrongly allocated additional space for the second variable
>
> (like I stated above) or if it issued a multiple allocation error.
>
>
>
> Anyone ever worked with a compiler like this and remember the compiler
>
> and operating system ?
>
>
>
> Thanks,
>
>
>
> Simon.
>
>
>
> PS: I've just tried it on Linux and binutils merged the two definitions
>
> for "unsigned long int a;" in different source files together without
>
> error just as expected and my test program treated them as one variable.
>
>
>
> --
>
> Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
>
> Microsoft: Bringing you 1980s technology to a 21st century world
Did you ever have the pleasure of working with Whitesmiths C?
I did, on RSX/IAS and (unofficially) on RT11. It had a number of
non-intuitive features, and I have a vague recollection that the
handling of "extern" (?) vars, with respect to defining and referencing
instances, might have been one of them. Or something like that,
something maybe not a million miles from your recollection.
PSECT attributes (OVR/CON? [NO]SHR?) also come into this, in some
circumstances.
Some info on potentially relevant Compaq C behaviours:
http://h71000.www7.hp.com/commercial/c/docs/5492p018.html
More information about the Info-vax
mailing list