Search code examples
gtkgtk3glib

what are G_BEGIN_DECLS and G_END_DECLS for?


I've been analyzing the code for some gtk applications and saw that in the .h files there are the G_BEGIN_DECLS and G_END_DECLS macros. The documentation says

Used (along with G_END_DECLS) to bracket header files

But I didn't understand what I meant.


Solution

  • These defines should be used in the public headers of C libraries. They aren't really useful for the library itself but they may be useful to C++ applications that want to use the library as they expand to a extern "C" block which makes sure that C++ compilers are able to handle the C headers