[C++-sig] embedding examples
Pierre Barbier de Reuille
pierre.barbier at cirad.fr
Thu Mar 4 09:19:04 CET 2004
Hi !
I use the interpreter with the CVS version of Boost. In my code I use
these lines to get the __main__ dict (and it works ...):
object main_module =
object(handle<>(borrowed(PyImport_AddModule("__main__"))));
object main_namespace = extract<dict>(
object(handle<>(borrowed(PyModule_GetDict(main_module.ptr())))) );
Pierre
On Mon, 2004-03-01 at 10:08, Ingo Luetkebohle wrote:
> Hi,
>
> I have trouble compiling the 'Using the interpreter' examples from the
> tutorial.
>
> Code like this:
> handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
> dict main_namespace(handle<>(borrowed(
> PyModule_GetDict(main_module.get()) )));
> results in
> error: variable declaration is not allowed here
>
> using gcc 3.2 and gcc 3.3 on Linux.
>
> When I use
> handle<> main_module(borrowed( PyImport_AddModule("__main__") ));
> handle<> main_nsh(borrowed( PyModule_GetDict(main_module.get()) ));
> dict main_namespace(main_nsh);
>
> it compiles and the resulting dict is usable.
>
> So, this is not a showstopper but it doesn't work as documented and
> results in longer code. Is there anything I can do to get the intended
> behaviour?
>
> regards
--
Pierre Barbier de Reuille
INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France
tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68
More information about the Cplusplus-sig
mailing list