GNOME Bugzilla – Bug 710862
Allow G_GNUC_PRINTF attribute to be added to methods
Last modified: 2016-11-09 20:49:08 UTC
I can’t find a way to get Vala to add the G_GNUC_PRINTF attribute to a method such as the following: namespace Folks.Internal { [PrintfFormat] private static void profiling_markv (string format, va_list args) { … } } Shouldn’t G_GNUC_PRINTF be put in the generated C code if [PrintfFormat] is used?
This is with Vala 0.22.0.26-f79fe.
G_GNUC_PRINTF is used to type check the format string. Vala already type checks it.
(In reply to comment #2) > G_GNUC_PRINTF is used to type check the format string. Vala already type checks > it. It might be useful for libraries used by C programs/libraries. In such case Vala wouldn't type check.
Yes, that's ok.
(In reply to comment #2) > G_GNUC_PRINTF is used to type check the format string. Vala already type checks > it. And for that reason, adding it shuts up a GCC warning (-Wsuggest-attribute=format).
Created attachment 339337 [details] [review] Add G_GNUC_PRINTF/SCANF attribute for Printf/ScanfFormat functions
Created attachment 339355 [details] [review] Add G_GNUC_PRINTF/SCANF attribute for Printf/ScanfFormat functions
This seems to do the trick for the libfolks headers and C code, thanks: -const gchar* folks_note_field_details_get_uid (FolksNoteFieldDetails* self); -void folks_note_field_details_set_uid (FolksNoteFieldDetails* self, const gchar* value); +const gchar* folks_note_field_details_get_uid (FolksNoteFieldDetails* self) G_GNUC_DEPRECATED; +void folks_note_field_details_set_uid (FolksNoteFieldDetails* self, const gchar* value) G_GNUC_DEPRECATED; -void folks_internal_profiling_point (const gchar* format, ...); +void folks_internal_profiling_point (const gchar* format, ...) G_GNUC_PRINTF(1,2); -void folks_internal_profiling_markv (const gchar* format, va_list args); -void folks_internal_profiling_point (const gchar* format, ...); +void folks_internal_profiling_markv (const gchar* format, va_list args) G_GNUC_PRINTF(1,0); +void folks_internal_profiling_point (const gchar* format, ...) G_GNUC_PRINTF(1,2);