This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
suggestion for new __attribute__ format archetype
- To: bug-gcc at gnu dot org
- Subject: suggestion for new __attribute__ format archetype
- From: Martin Pool <mbp at linuxcare dot com dot au>
- Date: Fri, 18 Aug 2000 11:35:00 +1000
glib and gtk+ make fairly heavy use of this idiom for passing a
variable-length list of parameters to a function:
g_strconcat("hello", " ", "world", NULL);
gtk_object_new("GtkButton", "x", 40, "y", 50, NULL);
I left the terminating NULL off the other day, which produced a
sigsegv as you would expect. It occurred to me that perhaps gcc could
know about this null-terminated list idiom in the same way it knows
about printf.
I'd suggest that perhaps it should even require that the last
parameter be known to be null at compile time. This:
char *addspace(char const *a, char const *b) {
return g_strconcat(a, " ", b);
}
might be OK if b was null, but for this idiom it would be a suspicious
usage and deserves a warning.
I though this would be a nice feature; make of it what you will.
Thanks,
--
Martin Pool, Linuxcare, Inc.
+61 2 6262 8990
mbp@linuxcare.com, http://www.linuxcare.com/
Linuxcare. Support for the revolution.
PGP signature