如何创建和读取在函数结束时未销毁的非全局变量?
我正在尝试编写一些与 MIDI 音序器一起使用的插件,但遇到了障碍。我无法使用全局范围变量来存储信息,因为可以存在共享内存的 .dll 的多个实例。
如何创建一个包含二维数组和其他变量的类(出于在其他插件中的可重用性目的),其内容将在函数之间共享?如果可能的话,我将如何从进行处理的框架中的函数读取和写入数据?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“DLL 的多个实例”是什么意思?在 Win32 中,每个进程都有自己的私有地址空间,并且具有全局变量的 DLL 是特定于该进程的。 DLL 不能多次加载到同一进程中。
在Win16的糟糕日子里,DLL全局变量空间在进程之间共享,这导致了无穷无尽的头痛。
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.
您是否在寻找
static
关键字?Are you looking for the
static
keyword?事实证明,这是一个 C++ 处女错误,我咳嗽只需要在插件类的咳嗽类声明中声明必要的变量。
感谢大家的帮助。我很可能会带着关于如何从具有各种古怪的指针和东西作为参数的类中获取信息的问题回来。
敬请关注! :)
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! :)