#43826: CodingStyle: compound literals Open Date: 2022-02-08 17:20 Last Update: 2022-02-08 17:51 URL for this Ticket: https://osdn.net//projects/freeciv/ticket/43826 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43826 --------------------------------------------------------------------- Last Changes/Comment on this Ticket: 2022-02-08 17:51 Updated by: alienvalkyrie Comment: There are two big questions here: For using them in general; is the issue with certain compilers (for C++ in particular?) not supporting them still a thing? For using them in the specific use case of #43809; can we depend on omitted pointer-valued struct members being initialized as NULL correctly in all cases (all platforms, all compilers)? I don't really know about the first question. If I had to guess, I'd assume most problems with that will have been solved or worked-around by now, given that compound literals have been in use for years now. Re: the second question – as far as I can tell without purchasing the official standards document from ISO, compound literal initialization works the same as struct initialization (1), where omitted members are zero-initialized (2), and zero-initialized pointers are set to appropriate null pointers (3), so the answer would be "yes". --------------------------------------------------------------------- Ticket Status: Reporter: alienvalkyrie Owner: (None) Type: Patches Status: Open Priority: 5 - Medium MileStone: 3.1.0 Component: Documentation Severity: 5 - Medium Resolution: None --------------------------------------------------------------------- Ticket details: Continued from #43809. Compound literals (which look similar to struct/unition initializers) are currently only used in very few places (most prominently, the requirement_fulfilled_by_* macros in common/requirements.h). We need to figure out / decide if and how we generally want to use them, and add that information to doc/CodingStyle. -- Ticket information of Freeciv project Freeciv Project is hosted on OSDN Project URL: https://osdn.net/projects/freeciv/ OSDN: https://osdn.net URL for this Ticket: https://osdn.net/projects/freeciv/ticket/43826 RSS feed for this Ticket: https://osdn.net/ticket/ticket_rss.php?group_id=12505&tid=43826