Trying to understand how and why to define



  • 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.



  • 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).



  • 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.



  • 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?



  • 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.



  • 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!


Log in to reply