471,350 Members | 2,001 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,350 software developers and data experts.

Visibility of symbols between extension modules

Hi all,
I have been learning to write extension modules using the C API that
python provides, and have hit a minor roadblock that is turning out to
be major headache.
My project essentially is organized as follows,

foo
|
---------------------------------
| | |
bar _foo baz

_foo basically does some init stuff, nothing much. Thats where the
problem starts. The "handler" variable which is initialized in _foo
isn't visible to others. One solution that worked was calling the
initializing function in each of the module's PyMODINIT_FUNC. Debugging
through the interpreter I found out the it loads all the .so's and
executes PyMODINIT_FUNCs. But by doing so, the routine to initialize the
handle gets executed three times, something which i find to be sort of
unclean.
The definition of the variable is included in a header and the sources
of the other modules include this master header, So I do have that
variable in scope, but its not initialized. _foo does the job of
declaring that variable.
I did my share of RTFM and found CObjects as a potential alternative.
But I feel its use rather complicated for a single variable that goes
out of scope. Is there any other way to solve this, or is my approach
itself borked =(?, What am I missing?

Thanks for your help
--
Sudharshan S
http://www.sudharsh.wordpress.com

Oct 21 '07 #1
0 812

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

47 posts views Thread by Pierre Barbier de Reuille | last post: by
1 post views Thread by wylbur via DotNetMonster.com | last post: by
reply views Thread by wASP | last post: by
1 post views Thread by zpinhead | last post: by
7 posts views Thread by 2b|!2b==? | last post: by
reply views Thread by sudharsh | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.