Declaring arrays without initial size

I am trying to compile Python bindings for OpenSSL (pyOpenSSL) on Windows Vista x64 using Visual Studio 2008. When I run python setup.py build_ext -IC:\OpenSSL\include , it dies with the following error:

 building 'OpenSSL.crypto' extension C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I\OpenSSL\include -IC:\Python26\include -IC:\Python26\PC /Tcsrc/crypto/x509name.c /Fobuild\temp.win-amd64-2.6\Release\src/crypto/x509name.obj x509name.c src/crypto/x509name.c(16) : error C2133: 'crypto_X509Name_methods' : unknown size error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe"' failed with exit status 2 

When I look at the source in question, I see the following on line 16:

 static PyMethodDef crypto_X509Name_methods[]; 

My C is very rusty, so I donโ€™t remember whether you can do it or not. Since this is a Python library, I would suggest that it was written for compilation in gcc, but I do not have the Cygwin environment installed on this computer. Is there any switch that I can use to compile this code with VS2008?

Answer:

The following is in the code:

 /* * ADD_METHOD(name) expands to a correct PyMethodDef declaration * { 'name', (PyCFunction)crypto_X509_name, METH_VARARGS } * for convenience */ #define ADD_METHOD(name) \ { #name, (PyCFunction)crypto_X509Name_##name, METH_VARARGS, crypto_X509Name_##name##_doc } static PyMethodDef crypto_X509Name_methods[] = { ADD_METHOD(hash), ADD_METHOD(der), ADD_METHOD(get_components), { NULL, NULL } }; #undef ADD_METHOD 

Rejecting Neil Butterworth's suggestion, I changed the line by mistake:

 static PyMethodDef crypto_X509Name_methods[]; 

in

 static PyMethodDef crypto_X509Name_methods[4]; 

and compiled code.

Thanks to everyone.

+4
source share
2 answers

You probably have this situation:

 #include <stdio.h> static int a[]; // declaration // lots of code int a[3]; // use 

which compiles like C with gcc. I'm not sure what he should (this is not true with C ++), but I do not have enough C lawyer to tell you for sure.

+5
source

Since it is static, it must be initialized with a constant size in some part of the compilation (C source file).

+5
source

All Articles