Page 1 of 1

linux glib g_node_append_data_ compile error

Posted: Wed Aug 20, 2025 2:39 pm
by dougmo52usr
The auto complete dropdown shows g_node_append_data_, and hitting tab inserts it in code, but the compiler fails saying g_node_append_data_ is not a function, array, list, map, or macro. g_node_new_ works. What am I missing to get access to glib functions code completion displays as present?

Re: linux glib g_node_append_data_ compile error

Posted: Wed Aug 20, 2025 3:41 pm
by mk-soft
Import not work because is deprecated (or a macro)
What do you want to do?

Link: https://docs.gtk.org/glib/func.node_append_data.html

Code: Select all


ImportC ""
  g_node_append_data (parent, daten)
EndImport

;test
g_node_append_data(0,0)

Re: linux glib g_node_append_data_ compile error

Posted: Wed Aug 20, 2025 3:58 pm
by mk-soft
Ok ...
It's a macro

You can also search for files content in linux file manager. Open to the folder "/usr/include" and search in it

Code: Select all

Macro g_node_append_data(parent, daten)
     g_node_insert_before_(parent, #Null, g_node_new_(daten))
EndMacro
;test
g_node_append_data(0,0)

Re: linux glib g_node_append_data_ compile error

Posted: Thu Aug 21, 2025 2:25 am
by dougmo52usr
Thanks for the help. I used your Macro g_node_append_data(parent, daten) example which works fine. However, I have a few questions.

I can use ImportC "/usr/lib/x86_64-linux-gnu/libglib-2.0.so", but ImportC "" doesn't compile on mine. Is there a project setting I need to use to specify location of libraries so that ImportC "" works for glib?

Are the declares for glib which are displayed in autocomplete available in a PB text file so I can study them? I see glib.imp but it is not text. I'd like to see how glib.imp is created and look at the source.

Re: linux glib g_node_append_data_ compile error

Posted: Thu Aug 21, 2025 10:39 am
by mk-soft
You only have to open the library file (.so) with OpenLibrary yourself in rare cases.
Most functions are fully implemented and sometimes with ImportC "" to define yourself.
Macros cannot be imported and must be written by yourself.

1. A so file cannot be imported but must be opened with OpenLibrary.
2. If a function is documented as a macro, you must write it yourself as a macro.
3. Specify standard libraries opened with OpenLibrary without a path. Paths and redirects are defined in the OS system.

OS functions already defined for PureBasic are listed in the file ../compilers/ApiFunctions.txt.
The IMP files are only a description of the API function with the parameters. They are not text files.