suggestion for new __attribute__ format archetype
Martin Pool
mbp@linuxcare.com.au
Thu Aug 17 18:36:00 GMT 2000
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,
--
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.2 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE5nJLEPGPKP6Cz6IsRAmCvAJ9s2WOskvGJBt2uCSrTdXgjTTOKaACgrD0f
nl1zpcmlryjEvi9E5QcgWjs=
=T4t0
-----END PGP SIGNATURE-----
More information about the Gcc-bugs
mailing list