Hello, I'm new to the mailing list but have been using python for a while.<br><br>I am now attempting to embed the interpreter into a C application but am having an issue when building a module exposing my application's functions to python.<br>
I do not know if this is the right place to ask for help with it, if it isn't then please let me know where to go.<br><br>the problem I'm having is with making a PyMethodDef array<br>When I make the array like this it works:<br>
<br><span style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);">static PyMethodDef ge_methods[]={</span><br style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);"><span style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);">  {"test",ge_test,METH_NOARGS,"Test returns 123L"},</span><br style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);">
<span style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);">  {NULL,NULL}</span><br style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);"><span style="background-color: rgb(255, 255, 255); color: rgb(204, 0, 0);">};</span><br style="background-color: rgb(51, 51, 255);">
<br>but as soon as I try to build the array from constant variables like this:<br><br><span style="color: rgb(204, 0, 0);">const int ge_test_args = METH_NOARGS;                       //The flag for this function</span><br style="color: rgb(204, 0, 0);">
<span style="color: rgb(204, 0, 0);">const char* ge_test_doc = "Test\nwill print \"test\"";        //The docstring</span><br style="color: rgb(204, 0, 0);"><span style="color: rgb(204, 0, 0);">static PyMethodDef ge_methods[]={</span><br style="color: rgb(204, 0, 0);">
<span style="color: rgb(204, 0, 0);">   {"test",ge_test, ge_test_args, ge_test_doc},                //simply replacing the flag and the docstring with a constant variable</span><br style="color: rgb(204, 0, 0);">
<span style="color: rgb(204, 0, 0);">   {NULL,NULL}</span><br style="color: rgb(204, 0, 0);"><span style="color: rgb(204, 0, 0);">};</span><br><br>the compiler then gives the following errors:<br>./test1.c:74: error: initializer element is not constant<br>
./test1.c:74: error: (near initialization for ‘ge_methods[0].ml_flags’)<br>./test1.c:74: error: initializer element is not constant<br>./test1.c:74: error: (near initialization for ‘ge_methods[0].ml_doc’)<br><br>I'm using the gcc compiler<br>
<br>This may well be because of my lack of understanding the C language but I was hoping someone could help me out, or at least point me in the right direction<br><br>I also posted about this at <a href="http://talk.christiandevs.com/viewtopic.php?f=13&t=2521">http://talk.christiandevs.com/viewtopic.php?f=13&t=2521</a><br>
<br>Thank you for any help<br><br><br clear="all">-- Maranatha!<br>---------------------------------<br>PFC aka Fezzik aka GAB<br>