[Info-vax] Possible C compiler static variable initialization problem.
David Froble
davef at tsoft-inc.com
Wed Feb 26 11:20:49 EST 2014
Simon Clubley wrote:
> On 2014-02-25, BillPedersen <pedersen at ccsscorp.com> wrote:
>> I have posted the description of the problem on the tickets section of VMS-Ports:
>>
>> https://sourceforge.net/p/vms-ports/tickets/79/
>>
>> Basically, I have a pointer to a structure that is statically initialized as
>> a Null and I then pass the address of that pointer to a function but the
>> information seen in the function is not a Null and so the function goes nuts.
>>
>> This is code which works on Linux...
>>
>
> If it works on Linux and not VMS, I would start by looking at the difference
> in linker behaviour.
>
> 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.
Yeah, this is what I'd expect. If it's a "local" variable in a module,
then the names says it all. Defining it "global" would mean it's the
same variable in more than one module.
> On Linux, the binutils linker combines them up into the same variable and
> only allocates the space for one variable.
Guess "local" and "module" don't mean anything to the Linux linker ....
> (I don't know if this has changed on VMS in recent versions as I don't write
> code, either on VMS or Linux, which depends on linker specific behaviour).
>
> That would be the first thing I would check for given the symptoms you have
> described.
>
> Simon.
>
More information about the Info-vax
mailing list