Compiling Rot2.0wolc on gcc 4

Posted by Cresus on Fri 12 Apr 2019 01:51 AM — 6 posts, 21,978 views.

#0
I've read to the forums and fixed some of the problems in merc.h and tables.h to move things around, now i get this error

[slowlane@condor src]$ make
gcc -c -Wall -O3 -g bit.c
bit.c:53: error: initializer element is not constant
bit.c:53: error: (near initialization for ‘flag_stat_table[0].structure’)
bit.c:54: error: initializer element is not constant
bit.c:54: error: (near initialization for ‘flag_stat_table[1].structure’)
bit.c:55: error: initializer element is not constant
bit.c:55: error: (near initialization for ‘flag_stat_table[2].structure’)
bit.c:56: error: initializer element is not constant
bit.c:56: error: (near initialization for ‘flag_stat_table[3].structure’)
bit.c:57: error: initializer element is not constant
bit.c:57: error: (near initialization for ‘flag_stat_table[4].structure’)
bit.c:58: error: initializer element is not constant
bit.c:58: error: (near initialization for ‘flag_stat_table[5].structure’)
bit.c:59: error: initializer element is not constant
bit.c:59: error: (near initialization for ‘flag_stat_table[6].structure’)
bit.c:60: error: initializer element is not constant
bit.c:60: error: (near initialization for ‘flag_stat_table[7].structure’)
bit.c:61: error: initializer element is not constant
bit.c:61: error: (near initialization for ‘flag_stat_table[8].structure’)
bit.c:62: error: initializer element is not constant
bit.c:62: error: (near initialization for ‘flag_stat_table[9].structure’)
bit.c:63: error: initializer element is not constant
bit.c:63: error: (near initialization for ‘flag_stat_table[10].structure’)
bit.c:64: error: initializer element is not constant
bit.c:64: error: (near initialization for ‘flag_stat_table[11].structure’)
bit.c:65: error: initializer element is not constant
bit.c:65: error: (near initialization for ‘flag_stat_table[12].structure’)
bit.c:66: error: initializer element is not constant
bit.c:66: error: (near initialization for ‘flag_stat_table[13].structure’)
bit.c:67: error: initializer element is not constant
bit.c:67: error: (near initialization for ‘flag_stat_table[14].structure’)
bit.c:71: error: initializer element is not constant
bit.c:71: error: (near initialization for ‘flag_stat_table[15].structure’)
bit.c:72: error: initializer element is not constant
bit.c:72: error: (near initialization for ‘flag_stat_table[16].structure’)
bit.c:73: error: initializer element is not constant
bit.c:73: error: (near initialization for ‘flag_stat_table[17].structure’)
bit.c:74: error: initializer element is not constant
bit.c:74: error: (near initialization for ‘flag_stat_table[18].structure’)
bit.c:75: error: initializer element is not constant
bit.c:75: error: (near initialization for ‘flag_stat_table[19].structure’)
bit.c:76: error: initializer element is not constant
bit.c:76: error: (near initialization for ‘flag_stat_table[20].structure’)
bit.c:77: error: initializer element is not constant
bit.c:77: error: (near initialization for ‘flag_stat_table[21].structure’)
bit.c:78: error: initializer element is not constant
bit.c:78: error: (near initialization for ‘flag_stat_table[22].structure’)
bit.c:79: error: initializer element is not constant
bit.c:79: error: (near initialization for ‘flag_stat_table[23].structure’)
bit.c:80: error: initializer element is not constant
bit.c:80: error: (near initialization for ‘flag_stat_table[24].structure’)
bit.c:81: error: initializer element is not constant
bit.c:81: error: (near initialization for ‘flag_stat_table[25].structure’)
bit.c:82: error: initializer element is not constant
bit.c:82: error: (near initialization for ‘flag_stat_table[26].structure’)
make: *** [bit.o] Error 1

bit.c lines are as follows:
const struct flag_stat_type flag_stat_table[] =
{
/* { structure stat }, */
{ area_flags, FALSE },
{ sex_flags, TRUE },
{ exit_flags, FALSE },
{ door_resets, TRUE },
{ room_flags, FALSE },
{ sector_flags, TRUE },
{ type_flags, TRUE },
{ extra_flags, FALSE },
{ wear_flags, FALSE },
{ act_flags, FALSE },
{ affect_flags, FALSE },
{ apply_flags, TRUE },
{ wear_loc_flags, TRUE },
{ wear_loc_strings, TRUE },
{ container_flags, FALSE },

/* ROM specific flags: */

{ form_flags, FALSE },
{ part_flags, FALSE },
{ ac_type, TRUE },
{ size_flags, TRUE },
{ position_flags, TRUE },
{ off_flags, FALSE },
{ imm_flags, FALSE },
{ res_flags, FALSE },
{ vuln_flags, FALSE },
{ weapon_class, TRUE },
{ weapon_type2, FALSE },
{ apply_types, TRUE },
{ 0, 0 }
};

Did I blow something up when I changed the merc.h tables to

extern const struct flag_type * area_flags;

from
extern const struct flag_type area_flags[];

-Thanks I'm trying ot remember stuff from long ago as my daughters are interested in coding. I'd like ot show them some times and they can see changes.
USA Global Moderator #1
Quote:
Compiling Rot2.0wolc

Uh huh. Link to your code files and also link to the originals so that we can see what you've changed and what the original looks like.
Amended on Fri 12 Apr 2019 02:20 AM by Fiendish
#2
sure- originally merc.h looked like this after reading a post in these forums:
/* bit.c */
extern const struct flag_type area_flags[];
extern const struct flag_type sex_flags[];
extern const struct flag_type exit_flags[];
extern const struct flag_type door_resets[];
extern const struct flag_type room_flags[];
extern const struct flag_type sector_flags[];
extern const struct flag_type type_flags[];
extern const struct flag_type extra_flags[];
extern const struct flag_type wear_flags[];
extern const struct flag_type act_flags[];
extern const struct flag_type affect_flags[];
extern const struct flag_type apply_flags[];
extern const struct flag_type wear_loc_strings[];
extern const struct flag_type wear_loc_flags[];
extern const struct flag_type container_flags[];

/* ROM OLC: */

extern const struct flag_type form_flags[];
extern const struct flag_type part_flags[];
extern const struct flag_type ac_type[];
extern const struct flag_type size_flags[];
extern const struct flag_type off_flags[];
extern const struct flag_type imm_flags[];
extern const struct flag_type res_flags[];
extern const struct flag_type vuln_flags[];
extern const struct flag_type position_flags[];
extern const struct flag_type weapon_class[];
extern const struct flag_type weapon_type2[];
extern const struct flag_type furniture_flags[];
extern const struct flag_type apply_types[];


now it looks like this:
/* bit.c */
extern const struct flag_type * area_flags;
extern const struct flag_type * sex_flags;
extern const struct flag_type * exit_flags;
extern const struct flag_type * door_resets;
extern const struct flag_type * room_flags;
extern const struct flag_type * sector_flags;
extern const struct flag_type * type_flags;
extern const struct flag_type * extra_flags;
extern const struct flag_type * wear_flags;
extern const struct flag_type * act_flags;
extern const struct flag_type * affect_flags;
extern const struct flag_type * apply_flags;
extern const struct flag_type * wear_loc_strings;
extern const struct flag_type * wear_loc_flags;
extern const struct flag_type * container_flags;

/* ROM OLC: */

extern const struct flag_type * form_flags;
extern const struct flag_type * part_flags;
extern const struct flag_type * ac_type;
extern const struct flag_type * size_flags;
extern const struct flag_type * off_flags;
extern const struct flag_type * imm_flags;
extern const struct flag_type * res_flags;
extern const struct flag_type * vuln_flags;
extern const struct flag_type * position_flags;
extern const struct flag_type * weapon_class;
extern const struct flag_type * weapon_type2;
extern const struct flag_type * furniture_flags;
extern const struct flag_type * apply_types;
USA Global Moderator #3
Where are TRUE/FALSE/area_flags/sex_flags/etc declared? Is this happening inside of a function or outside of a function?

Can you please just link to the files so I can download them and look at everything?
#4
yes, i downloaded it from here

http://mudmagic.com/codes/download/diku/merc/rom/rot/

rot2.0v5
USA Global Moderator #5
So I downloaded the code from that link and I made the following changes to get it to compile on a mac. Some of these will be macOS-specific.

1. I created an obj directory inside of src.

2. (unix-based-specific) At the top of merc.h, I put
#define unix
because otherwise it doesn't pick up where the directories and stuff are because those ifdefs are old and busted.

3. (probably macOS-specific) I replaced all instances (in act_wiz.c and act_wiz2.c) of
#include <wait.h>
with
#include <sys/wait.h>


4. (probably macOS-specific) I replaced all instances (in save.c and whoweb.c) of
#include <malloc.h>
with
#include <sys/malloc.h>


5. In string.c I replaced getline with getLine, because getline conflicts with the function from stdio.h ( https://linux.die.net/man/3/getline )

6. In tables.h I moved all of the structs from the bottom of the file up to the top of the file.


That's it. Then it compiles using make. Whatever forum post you read is terrible and wrong, lol. Also you know that gcc 4 is like 15 years old, right? Obviously just my opinion, but you shouldn't hobble yourself with such an old version of gcc.