Page 1 of 1
Why the underscore behind gtk_window_set_icon_ ???
Posted: Sat Mar 05, 2022 12:58 pm
by Joris
This works but ...
gtk_window_set_icon_(WindowID(Window_0), GetGadgetPixbuf(?icon, size))
But, why does this function have to be named with the _ underscore behind gtk_window_set_icon_ ?
In the Gtk-library it is simply gtk_window_set_icon, yet the function doesn't have to be imported too, so can anyone explain a bit about all that ?
More about things here :
https://www.purebasic.fr/english/viewt ... e&start=15
Thanks
P.s. It's a choice, keep doing things without understanding them or learning something new.
Re: Why the underscore behind gtk_window_set_icon_ ???
Posted: Sat Mar 05, 2022 2:26 pm
by AZJIO
Joris wrote: Sat Mar 05, 2022 12:58 pm
But, why does this function have to be named with the _ underscore behind gtk_window_set_icon_ ?
To make the compiler distinguish it from regular functions
Re: Why the underscore behind gtk_window_set_icon_ ???
Posted: Sat Mar 05, 2022 7:56 pm
by Tenaja
What he said.
OS API calls use that nomenclature to denote a function that you aren't defining in your code, so you don't have to declare it as an external function
It's a syntactical decision Fred made to give us a shortcut to API calls, without locking us out of using those function names in our own code. Between all of the OS's, there's so many api functions that it's statistically likely to have name collisions otherwise.
Re: Why the underscore behind gtk_window_set_icon_ ???
Posted: Sun Mar 06, 2022 10:15 am
by Joris
Hi,
My point is more, why do some need that underscore and others not (like these below) ?
When or how to know, it needs the underscore or it needs to be imported ?
Thanks
Code: Select all
ImportC ""
gtk_button_set_image(*button.GtkButton, *image.GtkWidget)
gtk_button_set_image_position(*button.GtkButton, position)
gtk_button_set_label(*button.GtkButton, label.p-utf8)
gtk_image_clear(*image.GtkWidget)
gtk_image_new_from_pixbuf(*pimg)
g_object_set(*object.GObject, property_name.p-utf8, *data, v= 0)
gdk_pixbuf_loader_new.i()
gdk_pixbuf_loader_write.l(*loader, *buffer, *count, *error)
gdk_pixbuf_loader_get_pixbuf.i(*loader)
gdk_pixbuf_loader_close(*loader, *error)
EndImport
Re: Why the underscore behind gtk_window_set_icon_ ???
Posted: Sun Mar 06, 2022 12:50 pm
by mk-soft
Many OS API functions are already imported. These can be called with underscore without extra import.