-
Notifications
You must be signed in to change notification settings - Fork 143
Devel GTK Sentinel warning
Simeon Andreev edited this page Feb 23, 2023
·
1 revision
In certain cases, you may encounter a warning: missing sentinel
compilation warning. This occurs when dealing with function calls that
have a terminator parameter, in order to signify the end of a variable
argument length function.
For example, see gtk_file_chooser_dialog_new()
defined in OS.java
as
follows:
/**
* @param title cast=(const gchar *),flags=no_out
* @param parent cast=(GtkWindow *)
* @param first_button_text cast=(const gchar *),flags=no_out
* @param terminator cast=(const gchar *),flags=sentinel
*/
public static final native long /*int*/ _gtk_file_chooser_dialog_new(byte[] title, long /*int*/ parent, int action, long /*int*/ first_button_text, int first_button_id, long /*int*/
second_button_text, int second_button_id, long /*int*/ terminator);
public static final long /*int*/ gtk_file_chooser_dialog_new(byte[] title, long /*int*/ parent, int action, long /*int*/ first_button_text, int first_button_id, long /*int*/
second_button_text, int second_button_id, long /*int*/ terminator) {
lock.lock();
try {
return _gtk_file_chooser_dialog_new(title, parent, action, first_button_text, first_button_id, second_button_text, second_button_id, terminator);
} finally {
lock.unlock();
}
}
Notice the flags=sentinel
for terminator parameter. This flag alerts
the compiler to the fact that this is a terminator value, and should be
regarded as Null
. This is necessary even if the function is only
called with a Null
value for the terminator. Adding this flag should
remove any sentinel warnings for that parameter.
For further reference/information, consult the SWT JNIGen Tool Metadata page.