MSVC "too many initializer" problem

Right now, if I were to enter the translatorshell and try to compile any of the snippets I will get an the following error: testing_1.c(2318) : warning C4047: 'initializing' : 'char *' differs in levels of indirection from 'int' testing_1.c(2318) : error C2078: too many initializers Which refers to this line (for this example): static globalfunctiondef_t globalfunctiondefs[] = { {&pypy_gfunc_sieve_of_eratosthenes, "pypy_gfunc_sieve_of_eratosthenes", {"sieve_of_eratosthenes", (PyCFunction)pypy_g_pyfn_sieve_of_eratosthenes, METH_VARARGS|METH_KEYWORDS, { 83,105,101,118,101,32,111,102,32,69,114,97,116,111,115,116,104,101,110,101, 115,10,32,32,32,32,10,32,32,32,32,84,104,105,115,32,111,110,101,32, 105,115,32,102,114,111,109,32,97,110,32,105,110,102,97,109,111,117,115,32, 98,101,110,99,104,109,97,114,107,44,32,34,84,104,101,32,71,114,101,97, 116,32,67,111,109,112,117,116,101,114,10,32,32,32,32,76,97,110,103,117, 97,103,101,32,83,104,111,111,116,111,117,116,34,46,10,10,32,32,32,32, 85,82,76,32,105,115,58,32,104,116,116,112,58,47,47,119,119,119,46,98, 97,103,108,101,121,46,111,114,103,47,126,100,111,117,103,47,115,104,111,111, 116,111,117,116,47,10,32,32,32,32}}}, { NULL } /* Sentinel */ }; I'm not too familiar with structure initialization in MSVC's compiler, but it seems to barf on that one. If anyone has a quick answer, then I am all ears, otherwise I'll have to do some research. -- Scott Dial scott@scottdial.com scodial@indiana.edu

Hi Scott, On Sat, Jul 29, 2006 at 12:48:46AM -0400, Scott Dial wrote:
Indeed, the line in question is not valid C at all. In gcc it just produces a lot of warnings and invalid data, but not an actual error :-/ This list of numbers is actually means to be the docstring of the function, but in this broken syntax gcc uses the first number only and interprets that number as a char*. So we get (char*)83 as the C-level docstring. You bet that accessing it via the __doc__ attribute of the built-in function gives a nice segfault... What is not tested is broken :-( I'll try to fix this. A bientot, Armin.

Hi Scott, On Sat, Jul 29, 2006 at 12:48:46AM -0400, Scott Dial wrote:
Indeed, the line in question is not valid C at all. In gcc it just produces a lot of warnings and invalid data, but not an actual error :-/ This list of numbers is actually means to be the docstring of the function, but in this broken syntax gcc uses the first number only and interprets that number as a char*. So we get (char*)83 as the C-level docstring. You bet that accessing it via the __doc__ attribute of the built-in function gives a nice segfault... What is not tested is broken :-( I'll try to fix this. A bientot, Armin.
participants (2)
-
Armin Rigo
-
Scott Dial