[Stackless] Can't embed Stackless in C++ using MinGW

Richard Tew richard.m.tew at gmail.com
Mon Sep 15 23:26:46 CEST 2008

On Sun, Sep 14, 2008 at 10:59 AM, Ben Sizer <kylotan at gmail.com> wrote:
> I'm trying to get started with embedding Stackless into C++.
> Unfortunately I don't seem to have even set it up right, because it
> won't compile. Python's include directory and the Stackless include
> directory are in my compiler's search path.

You have not mentioned where you obtained the Stackless source code
from, can you please clarify this?

So just to be explicit, because I like to know these things for sure, you have:
in your include paths, and no other clashing Python include directories?

> If I comment out the #include <stackless_api.h>, it compiles fine. But
> if I leave that in, I get this:
> E:/code/Python25/include/Stackless/stackless_api.h:45: error: expected
> constructor, destructor, or type conversion before '*' token
> E:/code/Python25/include/Stackless/stackless_api.h:52: error: variable
> `PyTasklet_Setup' definition is marked dllimport.
> E:/code/Python25/include/Stackless/stackless_api.h:52: error:
> `PyTaskletObject' was not declared in this scope
> E:/code/Python25/include/Stackless/stackless_api.h:52: error: `task'
> was not declared in this scope
> ...etc...

This should include (via 'core\stackless_impl.h') 'Python.h' and
'stackless.h' (via 'Python.h') as well.  It is sufficient to just
include 'stackless_api.h' and neither of 'Python.h' or 'stackless.h'
because of this.

That you are getting these errors indicates that Stackless does not
support your platform.  Or that you have bad include paths for your
compiler perhaps, hence my question above.

> I browsed through some headers and it appears some require '#define
> STACKLESS'. That is in <stackless.h>, so I #included that and got
> these errors:

Which points more towards the bad compilation environment/include
paths.  When you were including 'Python.h', you should have been
including 'stackless.h' as mentioned above, and if things were set up
right, at best you should have been seeing this then.

> Compiling: main.cpp
> In file included from
> E:/code/Python25/include/Stackless/core/stackless_impl.h:17,
>                 from E:/code/Python25/include/Stackless/stackless_api.h:37,
>                 from E:\code\cpp\stackless_embed\main.cpp:4:
> E:/code/Python25/include/Stackless/core/stackless_structs.h:172:
> error: ISO C++ forbids declaration of `PyFrame_ExecFunc' with no type
> E:/code/Python25/include/Stackless/core/stackless_structs.h:172:
> error: expected `;' before '*' token
> In file included from
> E:/code/Python25/include/Stackless/core/stackless_impl.h:18,
>                 from E:/code/Python25/include/Stackless/stackless_api.h:37,
>                 from E:\code\cpp\stackless_embed\main.cpp:4:
> E:/code/Python25/include/Stackless/pickling/prickelpit.h:14: error:
> `PyFrame_ExecFunc' has not been declared
> E:/code/Python25/include/Stackless/pickling/prickelpit.h:15: error:
> `PyFrame_ExecFunc' has not been declared
> At this point, I'm stuck. I couldn't find any walkthroughs on any of
> the various wikis for how to set up Stackless in C++, so I don't know
> what to try next. Any suggestions?

Look into what I have mentioned above.  There are inconsistencies in
the information you have provided which points to this being a problem
with your deve environment, rather than Stackless itself.

You can see some embedding examples here:


More information about the Stackless mailing list