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

JF Mezei jfmezei.spamnot at vaxination.ca
Wed Feb 26 00:02:50 EST 2014


On 14-02-25 23:36, BillPedersen wrote:
> I have posted the description of the problem on the tickets section of VMS-Ports:
> 
>      https://sourceforge.net/p/vms-ports/tickets/79/

What is "_stringlist"  ???

You mention that the
##
_stringlist *dblist = NULL;

This happens to be in the file with the failing function. Then in the
header file shared by two files I have:
##


The main program has:
##
extern _stringlist *dblist;

And in the file which calls the failing function I have:

    add_stringlist_item(&dblist, "regression");
##


Because the *dblist = NULL is not declared as "extern", it is just a
variable local to the compilation unit and not seen by the main program.

The main program has an uninitialized dblist which is passed to
add_stringlist.

You need both declarations to be "extern" to tell the linker to make
sure that all references to dblist refer to the same external storage.



More information about the Info-vax mailing list