Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2002:
[Freeciv-Dev] Re: [FreeCiv-Cvs] vasc: Added cast to placate g++.
Home

[Freeciv-Dev] Re: [FreeCiv-Cvs] vasc: Added cast to placate g++.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [FreeCiv-Cvs] vasc: Added cast to placate g++.
From: Vasco Alexandre Da Silva Costa <vasc@xxxxxxxxxxxxxx>
Date: Tue, 12 Feb 2002 20:27:31 +0000 (WET)

On Tue, 12 Feb 2002, Raimar Falke wrote:

> You made a lot of changes like this:
> 
> diff -X real_clean/diff_ignore -urd real_clean/common/astring.c 
> freeciv.clean/common/astring.c
> --- real_clean/common/astring.c Sun Feb 10 22:36:42 2002
> +++ freeciv.clean/common/astring.c      Tue Feb 12 09:04:04 2002
> @@ -76,7 +76,7 @@
>    /* allocated more if this is only a small increase on before: */
>    n1 = (3*(astr->n_alloc+10)) / 2;
>    astr->n_alloc = (n > n1) ? n : n1;
> -  astr->str = fc_realloc(astr->str, astr->n_alloc);
> +  astr->str = (char *)fc_realloc(astr->str, astr->n_alloc);
>  }
> 
> These are bad changes IMHO. Casting the return type of malloc is
> unnecessary for plain C and it can mask errors like you forgot to
> include "stdlib.h" (or "mem.h").
> 
> In short: freeciv is C and not C++ (were such casts are required).

Well, IIRC some parts of the code already added the casts. So IMHO its not
that bad to add them in this case. Some other warnings by g++ were valid
even for C code, like intermixing enums and ints in strange ways, and
missing includes. And extra -W flags can trap those include errors you
mention.

Besides this, i think we should aim to make freeciv compileable with a C++
compiler, just to keep our options open. K&R 2nd edition is a C book, and
nonetheless all code contained therein is valid C++.                            
    
Of course, if people don't like the casts that much, i can remove them    
again.

---
Vasco Alexandre da Silva Costa @ Instituto Superior Tecnico, Lisboa






[Prev in Thread] Current Thread [Next in Thread]