By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,523 Members | 1,737 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,523 IT Pros & Developers. It's quick & easy.

defining extern variables in pyrex

P: n/a
Hi All,

I've inherited a c library and is the process of wrapping it using
Pyrex. The library code is a state machine and remembers previous values
in order to determine new values on, for example, a decode() call. These
"state-full" variables were all implemented using 'extern' in the c
code.

My wrapper works fine if I have only one instance of my new type
myclass. However, when I create more than one instance of myclass it
seems that the different instances each share the same extern variables.
And of course when one method call on a instance manipulates the
internal state machine it invalidates the other instance's state. I
guess this makes sense...

So, how do I define variables in the pyrex wrapper that is visible as
extern c values but are private to a instance ? Take a look at the
example, both val2 and val1 are defined as extern in some .h or .c files
in the library, val2 is visible but not private to myclass, val1 is
private to myclass but when I import myclasslib I get undefined symbol
errors like these:

ImportError: ./codex/efr/src/libgsmefr.so: undefined symbol: past_gain

example:
cdef short val2
cdef class myclass:
cdef short val1
I reckon that if I can define all the state-full vars in the same scope
as val1 and convince Pyrex (and the linker, I guess) that these are the
elusive externs I wouldn't need to go through the pain of passing these
state-full vars down each method call,

Do I have any hope of doing it this way ?

regards
Thys
Jul 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.