Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Cinema not loading plugin with global string

    SDK Help
    0
    5
    474
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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;
      }
        
      // ...
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

          On 23/05/2013 at 06:26, xxxxxxxx wrote:

          Thanks, Wilfried.

          -Nik

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post