tags:

views:

136

answers:

8

Lost on this part of the code.


    const struct editor_cmd_type editor_table[] =
    {
    /*  {   command         function        }, */

        {   "area",         do_aedit        },
        {   "room",         do_redit        },
        {   "object",       do_oedit        },
        {   "mobile",       do_medit        },
        {   "mpcode",       do_mpedit       },
        {   "hedit",        do_hedit        },

        {   NULL,           0,              }
    };
Errors I am getting:
olc.c:652: error: âdo_aeditâ was not declared in this scope
olc.c:653: error: âdo_reditâ was not declared in this scope
olc.c:654: error: âdo_oeditâ was not declared in this scope
olc.c:655: error: âdo_meditâ was not declared in this scope
olc.c:656: error: âdo_mpeditâ was not declared in this scope
olc.c:657: error: âdo_heditâ was not declared in this scope
make: *** [olc.o] Error 1

There is already void do_aedit, void do_redit and such in the code...what am I missing?

A: 

Looks like you have some illegal whitespace characters in your code (or you pasted the errors incorrectly.) If the former try un-pretty-printing the code by replacing all whitespace with a single space.

fbrereto
A: 

That sounds like olc.h hasn't been #included.

chaos
+1  A: 

You say that void do_aedit etc. are defined in the code, but from the compiler errors it sounds like these are undefined in the file, olc.c (where the shown code is presumably). Are the functions declared before the shown code? If they are in another file, is it included?

DeusAduro
+1  A: 

have you tried either including the relevant header files or externing all the functions before the array?

ie If the function prototype is

void Function( void* param );

then add

extern void Function( void* param );

before the array. Ideally you want to be including the correct header file.

Goz
A: 

Codebase: Rom24b6

Where are the const coming from? Guessing editor_table, here is that code:

  /* Search Table and Dispatch Command. */
    for ( cmd = 0; editor_table[cmd].name != NULL; cmd++ )
    {
        if ( !str_prefix( command, editor_table[cmd].name ) )
        {
            (*editor_table[cmd].do_fun) ( ch, argument );
            return;
        }
    }

Here is the void aedit and such where I believe they should be defined already.

void do_aedit( CHAR_DATA *ch, char *argument )
{
    AREA_DATA *pArea;
    int value;
    char arg[MAX_STRING_LENGTH];

    if ( IS_NPC(ch) )
        return;

    pArea       = ch->in_room->area;

    argument    = one_argument(argument,arg);

    if ( is_number( arg ) )
    {

The rest are basically the same as that.

You should add this information to your question, rather than putting it in an "answer".
Kristopher Johnson
A: 

Okay, you need to include function prototypes for each of the do_ functions in the olc.c file. You can do this like this:

void do_aedit(CHAR_DATA *ch, char *argument);

Just add a line like that for each function that's missing in the top of the olc.c file, and try compiling again.

Daniel Bingham
A: 

Check whether do_aedit, do_redit, etc. are in the global namespace, or if they need to be qualified by namespace or classname.

It might help if you show us the definitions or declarations of those functions.

Kristopher Johnson
A: 

Thank you Alcon, and Goz. Externs worked. Sorry for all the confusion, first time on these boards but I am certainly thankful for the help.