Follow-up Comment #6, bug #15563 (project freeciv):

>> Comment to the code: please move variable definition to the start of the
function ('int chance, rate;' in get_info_label_text_popup()).
> What's the issue here? (The variables are declared at the start of a block,
so this code is not C99-only.)
Ah. I see the coding style actually says "Freeciv is programmed in plain C
with some C99 features. This means that: [...] Declaring variables in the
middle of the function body is forbidden".

So my code does transgress what is written by declaring variables at the
start of a block within a function, but so does lots of existing code (random
examples: client/tilespec.c:scan_specfile(),
server/unittools.c:maybe_make_veteran()).

Is this really the intention, or is it desired to forbid declaring variables
in the middle of a _block_ (which really is a C99-ism), for example:


  void f(void)
  {
     do_stuff();
     int x, y; /* BAD */
     do_more_stuff(&x, &y);
  }


Personally I think that reducing scope of variables in blocks (as permitted
in C90) rather than piling them up at the top of the function increases
clarity, but I'll go with whatever the local style is.

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?15563>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to