Compiling netCDFmodule on NT: Error

Gordon McMillan gmcm at hypernet.com
Thu May 27 23:00:51 EDT 1999


Hoon Yoon writes:
> 
>   After rediscovering compile.py by David, I am on the way to
>   compiling
> some addin modules.
>   One of the things that I really want to check out is Konrad's
> netCDFmodule. When I attempt to compile it, I get following error.
> 
> --------------------Configuration: netcdf - Win32
> Release--------------------
> Compiling...
> netcdfmodule.c
> H:\Python\netCDFmodule\netcdfmodule.c(780) : error C2491:
> 'PyNetCDFFile_Type' : definition of dllimport data not allowed
/snip/
> demo.dll - 2 error(s), 0 warning(s)
> (780)----
> statichere PyTypeObject PyNetCDFFile_Type = {
>   PyObject_HEAD_INIT(NULL)
>   0,		/*ob_size*/
>   "NetCDFFile",	/*tp_name*/
>   sizeof(PyNetCDFFileObject),	/*tp_basicsize*/
>   0,		/*tp_itemsize*/
>   /* methods */
>   (destructor)PyNetCDFFileObject_dealloc, /*tp_dealloc*/
>   0,			/*tp_print*/
>   (getattrfunc)PyNetCDFFile_GetAttribute, /*tp_ge

Without looking any closer, I'd say that statichere is a #define. It 
is apparently trying to #define __declspec(__dllimport), which 
doesn't make sense.

__declspec(__dllimport) would generally be used in a header that is 
declaring stuff implemented in a dll. __declspec(__dllexport) would 
make slightly more sense here (declaring that this is something to 
be exported from the dll), except that the only thing that should 
need that is the initcdfmodule function. Python goes around the OS 
and get's it's own pointers to everything else it needs.

This is one major difference between .so's and .dll's. The former 
export everything that would be visible in a plain .o, the latter 
only exports things explicitly marked for export. Since the module 
was written by a known *nixen <wink>, you may have to mess with the 
#define a bit.

- Gordon




More information about the Python-list mailing list