[Info-vax] Possible C compiler static variable initialization problem.

David Froble davef at tsoft-inc.com
Wed Feb 26 15:29:21 EST 2014


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.
> 

I'm so confused ....  familiar territory for me ...

Is this discussion about multiple modules (think PSECT), or is it about 
multiple source files fed to a compiler to form a single module ????



More information about the Info-vax mailing list