Cinema not loading plugin with global string
-
On 21/05/2013 at 09:20, xxxxxxxx wrote:
User Information:
Cinema 4D Version:
Platform:
Language(s) :---------
Why does Cinema not load a plugin file with a String variable in the global scope? This is very
annoying.#include <c4d.h> String g_string; Bool PluginStart() { return TRUE; } // ...
-
On 21/05/2013 at 11:38, xxxxxxxx wrote:
Originally posted by xxxxxxxx
<ADDRESS>
User Information:
Cinema 4D Version:
Platform:
Language(s) :---------
</ADDRESS> Why does Cinema not load a plugin file with a String variable in the global scope? This is very
annoying.#include <c4d.h>[/DIV][DIV][/DIV][DIV]String g_string;[/DIV][DIV][/DIV][DIV]Bool PluginStart() {[/DIV][DIV]<span ="Apple-tab-span" style="white-space:pre"> </span>return TRUE;[/DIV][DIV]}[/DIV][DIV][/DIV][DIV]// ...
Because the C4D OS pointer isn't valid before reaching PluginStart. Unfortunately non POD datatypes (http://www.cplusplus.com/reference/type_traits/is_pod/) need to allocate memory and for static global variables the compiler will try create them before you've reached PluginStart.
Best regards,
Wilfried
-
On 23/05/2013 at 06:26, xxxxxxxx wrote:
Thanks, Wilfried.
-Nik
-
On 23/05/2013 at 10:27, xxxxxxxx wrote:
The first question is why do you need global C4D::String ?
Because C4DOS is NULL at the time global variables are initialized it is not possible without a change / hack on C4D::String class.
-
On 23/05/2013 at 10:40, xxxxxxxx wrote:
I don't need this in one of my plugins, but I needed it for a quick test. I used a pointer instead
and was even too lazy to free it in PluginEnd().See https://developers.maxon.net/forum/topic/7185/8213_storing-objects-in-a-list&PID=34181#34181