> I am trying to install the race/class snippet and I am getting undeclared ch > errors in this code. > > void display_classes(struct descriptor_data *d) { > int x; > > send_to_char("Class selection menu - please choose a > class\r\n--------------- > -----\r\n", d->character); > for (x = 0; x < NUM_CLASSES; x++) > if (class_ok_race[(int)GET_RACE(ch)][x]]) > send_to_char(class_display[x], d->character); > send_to_char("\nClass: ", d->character); > } > > I cannot figure out why I am getting this error as GET_RACE(ch) is the > variable not ch, When I added races I added > #define GET_RACE(ch) ((ch)->player.race) Okay. Given the code above, where do you define/declare the variable 'ch' ? I see you define 'x', and later on it's declared in the 'for' loop. The first time you use ch, it's inside the macro. What is it? (hint, the descriptor_data structure has a member named 'character') As for the macro, thats nice if that variable it references also exists. However all a macro does is replace previously existing code. If you see a macro; #define MACRO(x) (x->member) and you use it in code like this; if(MACRO(avariable)) it's replaced by the c preprocessor with; if(avariable->member) In your case, 'GET_RACE(x)' is simply replaced with ((x->player.race)). Pretty simple, and really, not about definition. PjD +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/11/01 PDT