Problem #1:

> const.c:516: initializer element is not constant
> const.c:516: (near initialization for
> `sp_class_table[0].class[0]')

> I'm stumped.  I don't know what to do.  I've tried
> entering a number manually, instead of having the
> function class_lookup return one, and I get an error

You cannot make function calls when initializing global structures.
This initialization is done at compile time, not run time.


Problem #2:

> function class_lookup return one, and I get an error
> because of the pointer (making an integer from pointer
> without a cast, or somesuch...)

First of all, when you post, please at least get the error
message right.  It's a warning about making a pointer from
an integer without a cast, not the other way around as you stated.

I wonder why the compiler would complain about that...
Maybe it's because it wants a pointer and you're giving it
an integer, without casting it to a pointer?

The fix is simple: initialize stuff with the data type it's expecting.

I'm just wondering why you're using an array of pointers to integers
for class.  If it were me, I would just be using an array of
integers.  It would be much simpler.


Dennis



On Thu, 25 Jul 2002, Greystar wrote:

> Hi, I'm creating a sort of remort system for my mud.
> At level 50, characters can specialize in a certain
> area, and then they will be set back to level 1, given
> skills, and be considered a specialized class, such as
> Wizard, Assassin etc.  All specalized classes are
> restricted to certain classes.
>
> Here's how I'm setting it up, for reference.  I'm
> having them retain their old class information, and
> just giving them new special class in addition.  So
> there's a struct for sp_class (merc.h):
>
> struct    sp_class_type
> {
>   char *  name;              /* the full name of the
> special class  */
>   char    who_name    [4];   /* Three-letter name for
> 'who' */
>   sh_int  attribute;         /* secondary attribute
>          */
>   char *  skills[5];         /* skills for the class
>     */
>   int * class[2];      /* what classes can be this */
> };
>
>
> Then in const.c, I've set up a sp_class table to put
> in all the new specialized classes:
>
> const struct sp_class_type
> sp_class_table[MAX_SP_CLASS] = {
>     {
>       "crusader", "Cru", STAT_STR,
>       {""}, {class_lookup("paladin"),
> class_lookup("cleric")},  /* line 517 */
>     },
>
>     {
>       "druid", "Dru", STAT_DEX,
>       {""}, {class_lookup("cleric"),
> class_lookup("wilder")},  /* line 521 */
>     },
>
> ..... etc etc
>
> The blank {""}s are where I will put in the skills
> that each class gets.  Right now I haven't gotten to
> implementing the new skills yet, so they're blank for
> now.
>
> The reason for having an array of ints called class is
> for determining what classes are able to specialize
> (remort) as that class.  So for Crusader, it should
> only allow clerics and paladins.  I wanted to do it
> this way because it would allow for less coding later
> on, when I do checks for class compatability, etc.
>
> So here's my problem....
>
> const.c:516: initializer element is not constant
> const.c:516: (near initialization for
> `sp_class_table[0].class[0]')
> const.c:516: initializer element is not constant
> const.c:516: (near initialization for
> `sp_class_table[0].class[1]')
> const.c:521: initializer element is not constant
> const.c:521: (near initialization for
> `sp_class_table[1].class[0]')
> const.c:521: initializer element is not constant
> const.c:521: (near initialization for
> `sp_class_table[1].class[1]')
> make: *** [obj/const.o] Error 1
>
>
> I'm stumped.  I don't know what to do.  I've tried
> entering a number manually, instead of having the
> function class_lookup return one, and I get an error
> because of the pointer (making an integer from pointer
> without a cast, or somesuch...)
>
> Thanks for reading.  Any help would be greatly appreciated.
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com
>
>


Reply via email to