0

I am trying to compile an old C program on Centos8 Linux and it is failing, i'd appreciate any help.

I have broken below into the Makefile used, the error and code.

Any help would be much appreciated.

Thank you.

Makefile:

CC              = gcc
C_FLAGS         =  -Wall -O0 -ggdb -march=i686 -m32 -DDEBUG=1
C_FLAGS2        =  -Wall -O4 -march=i686 -s
LIBS            =  -lcrypt -lmysqlclient


Error

gcc -c -Wall -O0 -ggdb -march=i686 -m32 -DDEBUG=1 chat.c
In file included from chat.c:12:
command.h:152:30: error: array type has incomplete element type ‘struct cmd_type’
 extern const struct cmd_type cmd_table[];
                              ^~~~~~~~~

command.h

#ifndef _COMMAND_H
#define _COMMAND_H


/* returns 0 if not a command, or if the command is handled "on the fly".
   otherwise, it handles it and returns 1 */
int execute_command(request_rec *r);



/* does that "print everything you've got" thing */
void archive_command(request_rec *r, user_rec **user_list, 
                 message_rec **message_list, char *title, char *topic,
                 int chat_open);

#define DECLARE_CHAT_CMD( cmd ) CHAT_CMD cmd
typedef int CHAT_CMD (request_rec *r, char  *message_text);
extern const struct cmd_type cmd_table[];

struct cmd_type
{
    char *name;
    CHAT_CMD *cmd;
    int rank;
    int room;
};

DECLARE_CHAT_CMD(do_admin);
DECLARE_CHAT_CMD(do_alink);
DECLARE_CHAT_CMD(do_archive);
DECLARE_CHAT_CMD(do_background);
DECLARE_CHAT_CMD(do_bgcolor);
DECLARE_CHAT_CMD(do_boot);
DECLARE_CHAT_CMD(do_bottom);
DECLARE_CHAT_CMD(do_box);
DECLARE_CHAT_CMD(do_bozo);
DECLARE_CHAT_CMD(do_close);
DECLARE_CHAT_CMD(do_color);
DECLARE_CHAT_CMD(do_commands);


#endif /* _COMMAND_H */
Darren
  • 11
  • 1
  • 4
    The compiler doesn't know the type of your array elements yet. Did you try to move the struct declaration above the array declaration? – Gerhardh Sep 01 '21 at 07:47
  • Why macros for simple definition `#define DECLARE_CHAT_CMD( cmd ) CHAT_CMD cmd` in makes no sense. – 0___________ Sep 01 '21 at 08:00
  • 1
    Overall, this code doesn't look like something worth salvaging. And not particularly complicated either, so I'd rewrite it from scratch. – Lundin Sep 01 '21 at 08:19

0 Answers0