[python-win32] Extension and local data on win32

Robert Olson olson@mcs.anl.gov
Mon, 11 Nov 2002 14:20:40 -0600

Hi --

I'm trying to use a library as an extension under win32. Internal to the 
library is a hierarchical typing system that uses as type identifiers the 
address of a structure describing the class; somethign like

struct object_type
	struct object_type *parent;
	func_t	initializer;

const struct object_type tobj_struct = {
     parent_obj, init_func

tobj_type = &tobj_struct;

Then later it tags objects using the tobj_type pointer.

The structure of the python interface is such that multiple extension 
modules are created, each linking in the C library that has the type 
structures. The problem is that when Windows loads the DLLs, it maps them 
into different address spaces. The result is that when an object created by 
calling one extension is passed through a method in another extension, 
comparisons made on the object pointers fail.

I can't change the behavior of this library; does anyone have any ideas on 
a solution? I've tried what MSDN howto Q109619 " Share All Data in a DLL" 
suggests by adding ["-section:.data,rws", "-section:.bss,rws"] to the 
extra_link_args keyword on the Extension in setup.py on all extensions 
built; no change.

Also, marking the structure with __declspec(dllexport) didn't help.

Thank you for any advice.