GNOME Bugzilla – Bug 363438
Abbreviated struct initialization breaks with Solaris forte compiler
Last modified: 2006-11-07 15:31:58 UTC
gnome-games-2.17.1/dependencies/libggz/numberlist.c in ggz_numberlist_new(): GGZNumberList list = {values: 0, min: -1, max: -1}; breaks with the Solaris forte (Sun Studio 11) compiler. Fix is to expand this to 4 lines: GGZNumberList list; list.values = 0; list.min = -1; list.max = -1; Attached patch does this.
Created attachment 75020 [details] [review] Expand struct initialization as described in bug report.
Created attachment 75247 [details] [review] Fix struct init issues in dependencies/ggzmod-ggz/ggzmod-ggz.c dependencies/ggzmod-ggz/ggzmod-ggz.c has similar issues to dependencies/libggz/numberlist.c so attaching this patch to this bug instead of opening a new one.
Created attachment 75249 [details] [review] More stuct init issues corrected. This patch includes more struct init issues that break the Solaris build. It also includes one instance where a void function was returning a value (ggzcore_game_set_server_fd in dependencies/ggzcore/game.c) where I simply removed 'return'.
Thanks for the patches, they are now in CVS. Please let me know if there are any other problems with using the Sun forte compiler.
I just found out that the forte compiler supports "designated initializers": GGZNumberList list = {.values= 0, .min= -1, .max= -1}; So, if you would prefer a compact initialization style, you can use the '.' plus '=' format. Apologies for not knowing this earlier.
BTW, the "designated initializers" change in comment #5 is a C99 feature, not a Solaris specific one so it will be safe for all modern compilers.