From: Bruno H. <br...@cl...> - 2016-11-10 00:54:43
|
Hi Sam, I need to correct your change of 2016-08-28 Sam Steingold <sd...@gn...> avoid the clang -Wgnu-designator warning * lispbibl.d (as_object, as_chart): use the new {.one_o=???} syntax instead of GNU old-style field designator extension {one_o:???} https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Designated-Inits.html The reason is that it introduces compilation errors when one attempts to use DEBUG_GCSAFETY with g++ < 4.7. DEBUG_GCSAFETY requires a C++ compiler and defines OBJECT_STRUCT. Look at this test program: ================================= foo.cc ================================= typedef unsigned long uintP; typedef signed long sintP; typedef struct { uintP one_o; } gcv_object_t; typedef uintP oint; typedef sintP soint; typedef gcv_object_t object; #define as_oint(expr) ((expr).one_o) // Works with any GCC but only with G++ >= 4.7. With clang no warning. #define as_object(o) ((object){.one_o=(o)}) // Works with any GCC and any G++. With clang it gives "warning: use of GNU old-style field designator extension" //#define as_object(o) ((object){one_o:(o)}) extern gcv_object_t a; extern oint b; oint foo () { return as_oint(a); } gcv_object_t bar () { return as_object(b); } ========================================================================== With G++ 4.6.4 and older: $ g++ -c foo.cc foo.cc: In Funktion »gcv_object_t bar()«: foo.cc:21:30: Fehler: expected primary-expression before »)« token foo.cc:21:30: Fehler: expected »)« before »{« token foo.cc:21:30: Fehler: expected »;« before »)« token foo.cc:21:30: Fehler: expected primary-expression before »)« token foo.cc:21:30: Fehler: expected »;« before »)« token The syntax .one_o=(o) appears to be more standard: it is described in Wikipedia [1] and the GCC documentation [2]. The syntax one_o:(o) is only documented in the GCC doc [2] and is marked as "obsolete since GCC 2.5". But with G++ 4.6.4 and older it's the only available syntax. Bruno [1] https://en.wikipedia.org/wiki/C_syntax#Designated_initializers [2] https://gcc.gnu.org/onlinedocs/gcc-6.2.0/gcc/Designated-Inits.html |