September 13th, 2003, 12:55 AM
Problem with static variable
I am using /MD compiler option to build my executables.
The executable contains a static variable "lib_ref_count" which is initialised to zero at start of code. I use Flexlm library a third party library along with my own built library say "test.lib" in my application.
Before trying to call any function of my library "test.lib",
I first initialise the library reference count in "lib_ref_count" say "lib_ref_count = 1". Only when this count > 0 say "lib_ref_count > 0", I can allow the call to any function in my library "test.lib". The problem i am facing now is the static variable "lib_ref_count" gets properly initialised to "1" but suddenly becomes zero after a call to function of Flexlmlibrary. Hence any function call to "test.lib" after this fails.
Can anyone just explain me what might be the actual cause of this problem and how to overcome this?
September 13th, 2003, 02:10 AM
Sounds like an bounds check problem. If you pass a pointer to a function, and that function writes to the data pointed to but writes beyond the intended bounds, then it is likely that it will corrupt adjacent data in the calling function. Check the parameters you are passing to the FlexLM function, especially the size and type of any parameters you are passing. You really need to post the code for more help than that, including all data declarations, and the prototype for the FlexLM function you are calling.
September 13th, 2003, 04:18 AM
Thnx a lot...It worked well..I initialised all members passed to the third party library. It is working now..Gr8..