24 Aug, 2009, Banner wrote in the 1st comment:
Votes: 0
Converting to C++ and am stumped by this error:

swgi@mud:~/swgicpp/src$ make
make -s swgi -j5

swgi@mud:~/swgicpp/src$ make
make -s swgi -j5
[- Compiling o/reset.o….
[- Compiling o/renumber.o….
cc1plus: warnings being treated as errors
renumber.cpp:39: error: `void renumber_area(CHAR_DATA*, AREA_DATA*, RENUMBER_AREA*, bool, bool)' hides constructor for `struct renumber_area'
make[1]: *** [o/renumber.o] Error 1
make: *** [all] Error 2
swgi@mud:~/swgicpp/src$
[/code]
[code]
// 39
void renumber_area( CHAR_DATA * ch, AREA_DATA * area, RENUMBER_AREA * r_area, bool area_is_proto, bool verbose );[/code]
24 Aug, 2009, Guest wrote in the 2nd comment:
Votes: 0
I'd have to guess that it's because the function has the same name as the structure that holds the data for the renumbering system.
24 Aug, 2009, Banner wrote in the 3rd comment:
Votes: 0
Samson said:
I'd have to guess that it's because the function has the same name as the structure that holds the data for the renumbering system.

That was it. Thanks.
24 Aug, 2009, Banner wrote in the 4th comment:
Votes: 0
[-   Compiling o/slicer.o….
slicer.cpp: In function `char* acctname(CHAR_DATA*)':
slicer.cpp:2232: error: invalid conversion from `char*' to `unsigned char*'
slicer.cpp:2234: error: invalid conversion from `char*' to `const unsigned char*'
slicer.cpp:2357: error: invalid conversion from `char*' to `const unsigned char*'
slicer.cpp:2358: error: invalid conversion from `const unsigned char*' to `const char*'
slicer.cpp:2358: error: initializing argument 1 of `size_t strlen(const char*)'
slicer.cpp:2359: error: invalid conversion from `const unsigned char*' to `const char*'
slicer.cpp:2359: error: initializing argument 2 of `char* strcpy(char*, const char*)'
slicer.cpp:2368: error: invalid conversion from `char*' to `unsigned char*'
make[1]: *** [o/slicer.o] Error 1
make: *** [all] Error 2
[/code]


[code]
char *acctname( CHAR_DATA * ch )
{
static char buf[MAX_STRING_LENGTH];
const unsigned char *name;
unsigned char *s;
int len;

*buf = '\0';
s = buf; //2232
len = 0;
name = ch->name; //2234
#define add_to_s(chr) (*s++ = chr, ++len)
for( ; *name && len < 15; ++name )
{
[/code]

[code]
}
if( len < 15 )
{
size_t namelen;
unsigned char *filler;
char fillerbuf[MAX_STRING_LENGTH];
const char *const fillers[] = { "gewhinnqnppali", "hmmithinkishou",
"ldinsertsomehi", "ddenmessagesin",
"thisforfuturec", "coderstolaughat",
"ireallyshouldb", "esleepingnowbu",
"timaddictedtot", "hisshit"
};

*fillerbuf = '\0';
name = ch->name; //2357
namelen = strlen( name );
strcpy( fillerbuf, name );
if( namelen == 3 )
strcpy( fillerbuf + namelen, fillers[0] );
else if( namelen > 11 || namelen < 3 )
strcpy( fillerbuf + namelen, fillers[9] );
else
strcpy( fillerbuf + namelen, fillers[namelen - 3] );

*s = '\0';
filler = fillerbuf + strlen( buf ); //2368

for( ; *filler && len < 15; ++filler )
{
if( isalpha( *filler ) )
{
switch ( tolower( *filler ) )
{
[/code]
24 Aug, 2009, David Haley wrote in the 5th comment:
Votes: 0
I think these are pretty clear – you're mixing signed and unsigned characters, and you can't do that. You need to figure out which type you actually want, and then make sure that everything is declared appropriately.
24 Aug, 2009, Kline wrote in the 6th comment:
Votes: 0
Most chars are signed (at least on my boxes) unless explicitly written as unsigned. So your "char buf" is signed and you later try to convert it with the unsigned. Do you really need an unsigned? If not/so, just change them to all fit the same signedness. For const, you can use const_cast<type>(item) to add/remove constness from something.
24 Aug, 2009, David Haley wrote in the 7th comment:
Votes: 0
I think that on many Mac systems chars are unsigned by default. But the point is that yes, just specify (or don't specify) the same signedness, and things should work. I'm not sure why you have things declared as unsigned chars, although I admit that I haven't looked at your code in too much detail.
24 Aug, 2009, Banner wrote in the 8th comment:
Votes: 0
o/accounts.o: In function `get_account(char*)':
/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/accounts.o: In function `get_account(char*)':
/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `last_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/accounts.o: In function `acc_char_playing(char*)':
/home/swgi/swgicpp/src/accounts.cpp:316: multiple definition of `cards_drawn'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:139: first defined here
o/accounts.o: In function `acc_char_playing(char*)':
/home/swgi/swgicpp/src/accounts.cpp:324: multiple definition of `deck'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:148: first defined here
o/accounts.o: In function `get_account(char*)':
/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/accounts.o: In function `get_account(char*)':
/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `mplist'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/accounts.o: In function `get_account(char*)':
/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `note_free'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_comm.o: In function `countlangs(int)':
/home/swgi/swgicpp/src/act_comm.cpp:3748: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/act_comm.o: In function `in_hell(char_data*)':
/home/swgi/swgicpp/src/act_comm.cpp:77: multiple definition of `cards_drawn'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:139: first defined here
o/act_comm.o: In function `in_hell(char_data*)':
/home/swgi/swgicpp/src/act_comm.cpp:80: multiple definition of `deck'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:148: first defined here
o/act_comm.o: In function `countlangs(int)':
/home/swgi/swgicpp/src/act_comm.cpp:3748: multiple definition of `mplist'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_comm.o: In function `countlangs(int)':
/home/swgi/swgicpp/src/act_comm.cpp:3748: multiple definition of `note_free'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_comm.o: In function `countlangs(int)':
/home/swgi/swgicpp/src/act_comm.cpp:3748: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_comm.o: In function `countlangs(int)':
/home/swgi/swgicpp/src/act_comm.cpp:3756: multiple definition of `last_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_info.o: In function `str_similarity(char const*, char const*)':
/home/swgi/swgicpp/src/act_info.cpp:2414: multiple definition of `cards_drawn'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:139: first defined here
o/act_info.o: In function `str_similarity(char const*, char const*)':
/home/swgi/swgicpp/src/act_info.cpp:2419: multiple definition of `deck'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:148: first defined here
o/act_info.o: In function `check_blind(char_data*)':
/home/swgi/swgicpp/src/act_info.cpp:965: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/act_info.o: In function `check_blind(char_data*)':
/home/swgi/swgicpp/src/act_info.cpp:965: multiple definition of `mplist'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_info.o: In function `check_blind(char_data*)':
/home/swgi/swgicpp/src/act_info.cpp:965: multiple definition of `note_free'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_info.o: In function `check_blind(char_data*)':
/home/swgi/swgicpp/src/act_info.cpp:966: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_info.o: In function `check_blind(char_data*)':
/home/swgi/swgicpp/src/act_info.cpp:966: multiple definition of `last_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_move.o: In function `toggle_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1459: multiple definition of `cards_drawn'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:139: first defined here
o/act_move.o: In function `toggle_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1464: multiple definition of `deck'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:148: first defined here
o/act_move.o: In function `remove_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1483: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/act_move.o: In function `remove_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1483: multiple definition of `mplist'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_move.o: In function `remove_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1483: multiple definition of `note_free'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_move.o: In function `remove_bexit_flag(exit_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1484: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_move.o: In function `has_key(char_data*, int)':
/home/swgi/swgicpp/src/act_move.cpp:1696: multiple definition of `last_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:64: multiple definition of `cards_drawn'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:139: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:73: multiple definition of `deck'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:148: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:100: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:100: multiple definition of `mplist'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:100: multiple definition of `note_free'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:100: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_obj.o: In function `advatoi(char*)':
/home/swgi/swgicpp/src/bet.h:94: multiple definition of `last_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_wiz.o: In function `do_holylight':
/home/swgi/swgicpp/src/act_wiz.cpp:4737: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here
o/act_wiz.o: In function `do_holylight':
/home/swgi/swgicpp/src/act_wiz.cpp:4737: multiple definition of `MOBtrigger'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1383: first defined here
o/act_wiz.o: In function `do_dnd':
/home/swgi/swgicpp/src/act_wiz.cpp:7915: multiple definition of `cards_drawn'
make[1]: *** [swgi] Interrupt
make: *** [all] Interrupt

swgi@mud:~/swgicpp/src$


I can assume this is from a double included file or something, but the line numbers it references don't include any files or even make mention of the functions and defines it is complaining about. I was told I could have been double including a file, so I went through and put all the ifndef protections into all my .h files, including mud.h The rest of the code compiles clean without a single warning until the linker errors.
24 Aug, 2009, David Haley wrote in the 9th comment:
Votes: 0
Let's start with

/home/swgi/swgicpp/src/accounts.cpp:301: multiple definition of `first_account'
o/imc.o:/home/swgi/swgicpp/src/imc.cpp:1385: first defined here

What exactly do those two lines say? Don't forget to make clean and remake first.
24 Aug, 2009, Banner wrote in the 10th comment:
Votes: 0
I have it down to this much. Any help?

o/imc.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
o/accounts.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
o/act_comm.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
o/act_info.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
o/act_move.o:(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
o/act_obj.o:(.eh_frame+0x11): more undefined references to `__gxx_personality_v0' follow
collect2: ld returned 1 exit status
make[1]: *** [swgi] Error 1
make: *** [all] Error 2
swgi@mud:~/swgicpp/src$




Edit: Eh, nevermind… I was compiling with colorgcc and changed it back to g++-4.3 and it compiled. Thanks. :)
24 Aug, 2009, Sharmair wrote in the 11th comment:
Votes: 0
The error is saying (pretty plainly I think) that you are defining (allocating memory) some
things (probably global objects) of the same name in more then one place that have global
visibility. The problem is most likely sloppy (non)use of extern with declaring a global
object. You will probably find that you are not using extern on the declaration in your
header file (and maybe not even defining the object in any c(pp) file).
24 Aug, 2009, Guest wrote in the 12th comment:
Votes: 0
What is colorgcc ??
24 Aug, 2009, Kayle wrote in the 13th comment:
Votes: 0
colorgcc is a script that parses gcc/g++ output and colorizes warnings as yellow, and errors to red to aid in quickly distinguishing between the two. I've never had any issues with it causing linker errors though. So that's got me a little stumped.
25 Aug, 2009, Banner wrote in the 14th comment:
Votes: 0
After C++ifying and attempting to use DLL, I get a bunch of errors like this for SOME of my commands and skills in the log files. I'm assuming it has to do something with the DLL thing not correctly associating it dynamically like it should, because I've verified that it seems to only error on commands that I did not add to mud.h in DECLARE_DO_FUN defines.How can I fix this?
Mon Aug 24 17:20:11 2009 :: Loading skill table
Mon Aug 24 17:20:11 2009 :: [*****] BUG: Error locating spell_destruction_orb in symbol table. ../src/swgi: undefined symbol: spell_destruction_orb
Mon Aug 24 17:20:11 2009 :: [*****] BUG: fread_skill: unknown skill/spell spell_destruction_orb
Mon Aug 24 17:20:11 2009 :: [*****] BUG: Error locating spell_farspeak in symbol table. ../src/swgi: undefined symbol: spell_farspeak
Mon Aug 24 17:20:11 2009 :: [*****] BUG: fread_skill: unknown skill/spell spell_farspeak


Some relevant code, maybe?:
#ifdef __cplusplus
#define DECLARE_DO_FUN( fun ) extern "C" { DO_FUN fun; } DO_FUN fun##_mangled
#define DECLARE_SPEC_FUN( fun ) extern "C" { SPEC_FUN fun; } SPEC_FUN fun##_mangled
#define DECLARE_SPELL_FUN( fun ) extern "C" { SPELL_FUN fun; } SPELL_FUN fun##_mangled

/*
* Function types.
*/
typedef void DO_FUN args( ( CHAR_DATA * ch, char *argument ) );
typedef bool SPEC_FUN args( ( CHAR_DATA * ch ) );
typedef ch_ret SPELL_FUN args( ( int sn, int level, CHAR_DATA * ch, void *vo ) );


SPELL_FUN *spell_function( char *name )
{
SPELL_FUN *funHandle = 0;
const char *error;

*(void**)( &funHandle ) = dlsym( sysdata.dlHandle, name );
if( ( error = dlerror( ) ) != NULL )
{
bug( "Error locating %s in symbol table. %s", name, error );
return spell_notfound;
}
return funHandle;
}

DO_FUN *skill_function( char *name )
{
const char *error;
DO_FUN *funHandle = 0;
*(void**)( &funHandle ) = dlsym( sysdata.dlHandle, name );

if( ( error = dlerror( ) ) != NULL )
{
bug( "Error locating %s in symbol table. %s", name, error );
return skill_notfound;
}
return funHandle;
}
25 Aug, 2009, ghasatta wrote in the 15th comment:
Votes: 0
Probably was invoking a different version of gcc.
25 Aug, 2009, ghasatta wrote in the 16th comment:
Votes: 0
Banner said:
, because I've verified that it seems to only error on commands that I did not add to mud.h in DECLARE_DO_FUN defines.How can I fix this?
:ghostface: Well, you identified a potential solution in your deduction. Try it out and see if it fixes the problem.
25 Aug, 2009, Banner wrote in the 17th comment:
Votes: 0
ghasatta said:
Banner said:
, because I've verified that it seems to only error on commands that I did not add to mud.h in DECLARE_DO_FUN defines.How can I fix this?
:ghostface: Well, you identified a potential solution in your deduction. Try it out and see if it fixes the problem.
That's not a solution. The purpose of dynamic command linking is so you don't have to have the defines..? Hence why they were absent in C-SWGI and now appear to be needed in C++-SWGI.
25 Aug, 2009, David Haley wrote in the 18th comment:
Votes: 0
Quote
The purpose of dynamic command linking is so you don't have to have the defines..?

The rules change when you cross the C/C++ border, due to C++ name mangling. In other words, if C++ sees a symbol "foo", it translates that to some modified form (say, __foo__argtype1__bla) for various reasons (e.g., overloading, whatever). If that symbol "foo" however exists as a C symbol, its object file will contain it as literally "foo" – and so the C++ linker will not be able to find it unless the C++ code wraps that declaration in extern "C". This tells the compiler to not apply name-mangling to that particular symbol.
0.0/18