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

    Trying to understand how and why to define

    SDK Help
    0
    6
    476
    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 02/06/2013 at 03:59, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :

      ---------
      I am trying to understand C++ and where constants are defined, so I have a few questions.
      First, the c4d_symbols.h and the c4d_strings.str files must have these names, right? Because Cinema 4D will look for these?

      Then, if I do this:
      in  c4d_symbols.h:

      LONG ID_MYCONSTANT_VALUE	= 1234567;
      

      I get this when C4D starts: Error reading resource file bla bla line 10

      But for some reason, this is allowed, if I put it in another file:
      my_own_custom_symbols.h:

      #include "c4d_symbols.h"
      LONG ID_MYCONSTANT_VALUE	= 1234567;
      

      I can get stuff to work, and should not let this occupy me. So I am wasting some time here. But I do want to know why , not only how, when writing my plugins.

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

        On 02/06/2013 at 04:11, xxxxxxxx wrote:

        c4d_symbols.h is an enumeration, so typeless. i do not think that you are allowed to place

        code outside of that enumeration. after all c4d_symbols.h is used to parse the dialog *.res
        and the c4d_string.str files. but you can place there some enum ids that neither do appear
        in a str or res file (and you want to use for some non gui stuff).

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

          On 02/06/2013 at 04:12, xxxxxxxx wrote:

          There are two levels of constant definitions.  The first is with 'global' definitions that are stored in c4d_symbols.h and c4d_strings.h.  These are loaded with the C4D Main as global resources.  The second is the plugin definitions which are loaded with the registration of the plugin.  Here you have the .h, .res, .str files associated with the plugin.

          You MUST use enum (enumerations) for the constant definitions in these files.  You can define them as const LONG XXXX = 1234; in a regular CPP file but not in files used as resource descriptions - as you noted.  Please examine the SDK examples for a better understanding of this.

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

            On 02/06/2013 at 04:15, xxxxxxxx wrote:

            Originally posted by xxxxxxxx

            c4d_symbols.h is an enumeration, so typeless. i do not think that you are allowed to place code outside of that enumeration.

            Thanks, I see. Who "decides" that? Is it Compiler "magic", or some definitions in the project or elsewhere?

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

              On 02/06/2013 at 04:29, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              Originally posted by xxxxxxxx

              c4d_symbols.h is an enumeration, so typeless. i do not think that you are allowed to place code outside of that enumeration.

              Thanks, I see. Who "decides" that? Is it Compiler "magic", or some definitions in the project or elsewhere?

              It has nothing to do with the compiler, the error msg has been raised by c4ds resource parser
              on c4ds startup. especially the rules for the c4d_symbols files are quite strict, i have never
              questioned them, i just do follow them.

              i think the parser even parses some sort of comments in the symbols files. at least the res editor
              produces a special symbols.h layout I try to follow. It does expect the file to end after the enum.
              So you cannot place there any constants / definitions / whatever.

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

                On 02/06/2013 at 06:10, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                It does expect the file to end after the enum.
                So you cannot place there any constants / definitions / whatever.

                Right - exactly what I was wondering about, now I know this!

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