Undefined calling conventions in Python.h

Jaco Naude naude.jaco at gmail.com
Wed Jul 23 14:22:19 CEST 2008


On Jul 23, 2:08 pm, Ben Sizer <kylo... at gmail.com> wrote:
> On Jul 23, 11:43 am, Jaco Naude <naude.j... at gmail.com> wrote:
>
> > What Visual C++ is doing is that it is looking for mangled names since
> > it does not know the DLL contains C functions. I've managed to work
> > around this by declaring the Python functions as follows before using
> > them in the C++ application side:
>
> > extern "C"
> > {
> >     void Py_Initialize(void);
>
> > }
>
> You should put the extern block around the #include <python.h> call
> rather than individual functions, as surely the C calling convention
> should apply to everything within.
>
> > It is probably more of a C++ question it turns out, but I would think
> > that someone in the Python group would use the Python DLL in C++.
>
> More of a Visual C++ question specifically, since the __clrcall prefix
> is a MS specific extension (http://msdn.microsoft.com/en-us/library/
> ec7sfckb(VS.80).aspx). If you're not using managed code in your app,
> disable it in the project/build options. If you are, then perhaps you
> just need to specify that you're not with this DLL, though I've never
> had to deal with anything like that myself.
>
> --
> Ben Sizer


Fredrik, thanks for the help. I'm not sure why but it seems to work
now even if I don't include the extern "C" command. It also works with
both Python.h files (after I copied pyconfig.h from the PC folder). So
it seems like everything is working now.

Ben, Thanks for the reply. Good suggestion to place the extern "C"
around the include. I will remember that. It turns out that it works
without that as well in the end. As for the question on managed code:
My application do use managed code. I've been able to turn this off
when I created the Python DLL and it seems to work.

Thanks for all the help,
All the best
Jaco



More information about the Python-list mailing list