开发者

How do I create and read non-global variables that aren't destroyed at end of function?

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 开发者_JAVA百科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?


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.


Are you looking for the static keyword?

static int i = 1; //this keeps its value at each call


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! :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜