Follow-up Comment #1, bug #13807 (project freeciv):

I'm not sure that we need to get rid of the static
'settings' array and use dynamic memory for settings,
since even with your approach there will still be at
least one variable global to the settings.c file.

If you are worried that you cannot use static initializers
with unions, you need not be, since you can use the
syntax:

union foo {
  int i;
  const char *s;
  bool b;
};

union foo f1 = { .b = TRUE };
union foo f2 = { .s = "hi" };

This could be a little more tricky though, since the
settings take the address of the int/bool. I think you
can just do

union pfoo {
  int *pi;
  bool *pb;
  char *ps;
};

union pfoo pf1 = { .pi = &value };

Of course please use much better variable and field
names than I do in the examples.


----------------------------------------------------------------
時間をかけていい名前を思いつく。

    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  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