Re: [Freeciv-Dev] [PATCH] include and comments
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Nicolas Brunel wrote:
> this patch is good but incomplete. If I have well followed what David
> wants to do, headers define functions available for other program (or part
> of the program). Include in a header file must contain all the
> necessary structs used in the header and only that.
Yep. Although also possible (and used in some places in the freeciv
sources) is if a header just uses some struct pointers for function
prototypes, you can just include an incomplete type in the header:
struct unit;
and then when the file is included in a compilation unit, typically
the header which gives the real "struct unit" will also be included
along the line and everything will be ok (and with fewer includes
inside other includes).
(But if you need an enum type, I guess this doesn't work and you
really need to include the header? Or if you need a real struct,
not just a struct pointer. Or, if you need lots of structs -- eg
packets -- its easier to just include the header.)
> So, in advdomestic, I will add "player.h" and "city.h", in ...
Or just:
struct player;
struct city;
struct ai_choice;
Though I'm not 100% sure if this is a good way to go or not...
> Another remark, we use #include "foo.h" for the FreeCiv headers and
> <foo.h> for the system/library/... headers.
Right.
> There will be lots of patches to integrate for 1.8.2 ! :)
Yep! :-)
Regards,
-- David
|
|