Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Use of undeclared identifier 'g_resource'

    Cinema 4D SDK
    3
    8
    1.6k
    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.
    • R
      rui_mac
      last edited by r_gigante

      I copied all the files from a shader, from the SDK and adjusted it all to accomodate my code.
      But I'm getting the error:

      Use of undeclared identifier 'g_resource'

      in the code:

      switch (id)
      {
      	case C4DPL_INIT_SYS:
      		if (!g_resource.Init())
      			return false;		// don't start plugin without resource
      
      		return true;
      }
      

      How come it is not declared, since it is completely based in the SDK?

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by

        Hi rui,

        with regard to the issue reported, it's likely you're not including c4d_resource.h in your project. Since I don't really know how you're proceeding to "migrate" your old plugins to R20, please have a look at both the *microsdk" Project in the SDK example set and to the Plugin Migration section found in our documentation.

        I also warmly suggest to have a look at this project on Github which was demoed during DevKitchen 2018 to see what has been adapted and how.

        Last but not least, feel free to describe your approach to migrate your plugins since this is not the first thread were issues on migrating are showing up.

        Looking forward your input, give best.
        Riccardo

        1 Reply Last reply Reply Quote 2
        • R
          rui_mac
          last edited by

          I did included the c4d_resource.h and the error disappeared.
          I was migrating by simply fixing the errors that appeared inside Xcode, until everything was clear.
          But now, I started by duplicating a similar plugin from the sdk and pasting just the parts of the code that belong to my plugin.

          1 Reply Last reply Reply Quote 1
          • R
            rui_mac
            last edited by

            My simplest shader plugin is already working 🙂
            The problem is with the other shader plugin that is compiling fine, shows up in Cinema 4D R20, but when I choose it, Cinema 4D crashes and I don't have the slightest idea in how to fix it.
            It worked fine in all versions from R14 to R19.

            1 Reply Last reply Reply Quote 0
            • r_giganteR
              r_gigante
              last edited by

              Hi Rui and thanks for following-up.

              With regard to the crash you're experiencing upon having the plugin compiled, I warmly suggest you to provide as many details as possible:

              • a clear description of the crash
              • the revision were the issue appears
              • the debug stack trace at the crash time
              • a list of other plugins already installed

              Without valuable information I can be of no help in identifying the potential cause of the crash and help you get rid of it.

              Best, Riccardo

              1 Reply Last reply Reply Quote 1
              • R
                rui_mac
                last edited by

                Thank you for the help, Riccardo.
                I will provide all that.
                I just need to know one thing. The debug stack trace is created by compiling the plugin in what mode? Testing or Profiling?
                And the debug stack trace report is in the log file that is produced when the crash occurs?
                Sorry, but I never needed to do this, so I really don't know what to do to produce a debug stack trace.

                1 Reply Last reply Reply Quote 0
                • a_blockA
                  a_block
                  last edited by

                  Hi Rui,

                  no worries, we'll get you there eventually.

                  Actually you do not need to do anything special. I assume, while developing your plugin you already compile it in debug mode. Then you should already be fine, when running C4D from within Xcode after successful compilation. You may want to add a few command line options to maybe get additional information (see Debugging in the SDK docs or this slightly outdated article about debugging plugins[URL-REMOVED] on our blog), but that's not mandatory in a first step. In general, when started from within Xcode your C4D is already running inside the debugger. If now any exception (like something resulting in a crash) occurs, you should be back in the debugger and Xcode should not only show the line in your plugin, where the crash occurred (not implying it's the cause) and you should be able to see the stack trace of that moment in one of Xcodes helper displays.

                  One more thing to maybe look out for: Xcode also has an output console, where C4D prints some information. Please also check this, maybe there are some hints, what went wrong shortly before the crash.

                  All of this might already give you a hint. But if not, then maybe we are able to pull some more information form this.

                  Cheers,
                  Andreas


                  [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

                  1 Reply Last reply Reply Quote 1
                  • R
                    rui_mac
                    last edited by rui_mac

                    Good news. And... more good news.

                    The best news are that, after creating a Debug version and running Cinema 4D R20 from XCode, all of a sudden, the plugin started working!!!
                    I then created a simple build (not a Debug one) and it is still working fine 🙂

                    The other good news is that I now know how to create a Debug version 🙂

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