COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 11-11-2020, 03:17 AM   #1
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 225
Default Static variables in functions are safe?

Is it safe to work with static variables in functions? For example, if I use this variable in the OnParamChange function
Code:
void VSTCLASS::OnParamChange(int id) {
	IMutexLock lock(this);
	static float last_val;
....
If the user loads multiple instances of my plugin on the same Host, is there a risk that the variable will become global for all these instances? Since I use the same name for the class and the same variable name?
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Old 11-12-2020, 07:57 AM   #2
olilarkin
Human being with feelings
 
Join Date: Apr 2009
Location: UK
Posts: 1,239
Default

no, it will be global for all instances running in the same process.

Don't do that unless in specialist circumstances, and then be very careful
__________________
VirtualCZ | Endless Series | iPlug2 | Linkedin | Facebook
olilarkin is offline   Reply With Quote
Old 02-14-2021, 01:57 PM   #3
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 225
Default

Thanks
__________________
Audio plugins | BrainWaveProducer | EmRysRa
SaschArt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:05 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.