1

I am attempting to code some plugins to use with MIDI sequencers but have hit a stumbling block. I can't use global-scope variables to store information because multiple instances of the .dll can exist which share memory.

How do I create a class (for re-usability purposes in other plugins) containing 2 dimensional array and other variables the content of which is to be shared between functions? If that is possible, how would I read and write the data from the function in the framework where I do the processing?

3 Answers3

1

What do you mean by "multiple instances of the DLL"? In Win32, every process has its own private address space, and DLLs with global variables are specific to that process. A DLL cannot be loaded more than once into the same process.

In the bad old days of Win16, DLL global variable space was shared between processes, which led to no end of headaches.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
  • Yes, sorry I should have been more specific. Resources are intentionally shared with this framework to avoid re-loading commonly shared stuff like GUI elements. – Paul Reilly Jan 06 '11 at 11:30
0

Are you looking for the static keyword?

static int i = 1; //this keeps its value at each call
user541686
  • 205,094
  • 128
  • 528
  • 886
0

It turns out that it was a C++ virgin error where I cough just needed to declare the variables necessary in the cough class declaration of the plugin class.

Thanks everyone for the help. I may well be back with questions about how to get info from classes that have all sorts of whacky pointers n stuff as arguments.

Stay tuned! :)