Why the underscore behind gtk_window_set_icon_ ???

Linux specific forum
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Why the underscore behind gtk_window_set_icon_ ???

Post 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.
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
AZJIO
Addict
Addict
Posts: 1360
Joined: Sun May 14, 2017 1:48 am

Re: Why the underscore behind gtk_window_set_icon_ ???

Post 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
User avatar
Tenaja
Addict
Addict
Posts: 1949
Joined: Tue Nov 09, 2010 10:15 pm

Re: Why the underscore behind gtk_window_set_icon_ ???

Post 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.
Joris
Addict
Addict
Posts: 885
Joined: Fri Oct 16, 2009 10:12 am
Location: BE

Re: Why the underscore behind gtk_window_set_icon_ ???

Post 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
Yeah I know, but keep in mind ... Leonardo da Vinci was also an autodidact.
User avatar
mk-soft
Always Here
Always Here
Posts: 5402
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

Re: Why the underscore behind gtk_window_set_icon_ ???

Post by mk-soft »

Many OS API functions are already imported. These can be called with underscore without extra import.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply