Help me? Pretty please?

Posted by Demitrus on Mon 24 Apr 2006 09:21 PM — 6 posts, 24,534 views.

#0
Alright, this becoming a rather large headache, and I get the same exact error for all the codebases I have tried to compile - From Dawn, to Rom24b6, To startermud, afkmud, basically every rom deritive in existance. Heres the problem:

string.c:699: error: conflicting types for 'getline'
/usr/include/sys/stdio.h:31: error: previous declaration of 'getline' was here
string.c:699: error: conflicting types for 'getline'
/usr/include/sys/stdio.h:31: error: previous declaration of 'getline' was here
make: *** [string.o] Error 1

---

Basically thats the error I get for every single codebase I try to compile. Any help would be greatly appreciated.
USA #1
What is your operating system? What is your environment? What is on line 699 of string.c?
#2
char *numlineas( char *string )
{
int cnt = 1;
static char buf[MAX_STRING_LENGTH*2];
char buf2[MAX_STRING_LENGTH], tmpb[MAX_STRING_LENGTH];

buf[0] = '\0';

while ( *string )
{
string = getline( string, tmpb );
sprintf( buf2, "%2d. %s\n\r", cnt++, tmpb );
strcat( buf, buf2 );
}

return buf;
}

/* buf queda con la linea sin \n\r */
char *getline( char *str, char *buf )
{
int tmp = 0;
bool found = FALSE;

while ( *str )
{
if ( *str == '\n' )
{
found = TRUE;
break;
}

buf[tmp++] = *(str++);
}

if ( found )
{
if ( *(str + 1) == '\r' )
str += 2;
else
str += 1;
} /* para que quedemos en el inicio de la prox linea */

buf[tmp] = '\0';

return str;


----------
Those are the two parts of code im having trouble with. Well, just one, for now. The getline.
#3
I forgot the closing bracket, heres the correct two sections of code -

char *numlineas( char *string )
{
int cnt = 1;
static char buf[MAX_STRING_LENGTH*2];
char buf2[MAX_STRING_LENGTH], tmpb[MAX_STRING_LENGTH];

buf[0] = '\0';

while ( *string )
{
string = getline( string, tmpb );
sprintf( buf2, "%2d. %s\n\r", cnt++, tmpb );
strcat( buf, buf2 );
}

return buf;
}

/* buf queda con la linea sin \n\r */
char *getline( char *str, char *buf )
{
int tmp = 0;
bool found = FALSE;

while ( *str )
{
if ( *str == '\n' )
{
found = TRUE;
break;
}

buf[tmp++] = *(str++);
}

if ( found )
{
if ( *(str + 1) == '\r' )
str += 2;
else
str += 1;
} /* para que quedemos en el inicio de la prox linea */

buf[tmp] = '\0';

return str;
}
USA #4
What is your operating system? What is your environment?

The getline problem has been covered here before; have you tried searching in the ROM section?
Basically you'll need to rename the function to something else, and change all references to getline in your source code to your new function name.


Also, please use the code tag when posting code.
USA #5
BTW, just to keep the record straight, AFKMud is not a ROM derivative and would not have been subject to this problem :)

The compiler error encountered is usually because you have a function sharing the same name as one from the standard includes. I don't recall hitting this with any of the stock Rom derivs I've tested but it is possible one or more flavors of GCC are to blame for this.

Best bet, find and rename the "getline" function in whatever file it's located in. Then rename all of the calls within the code to use the new name.