[Glade-users] MSVC and glade_xml_signal_autoconnect



Hi,

The executable builds and runs with the exception of the 
"glade_xml_signal_autoconnect" function call.  When I make this function 
call, I get errors from libglade stating that it can't find the signal 
handlers.  I thought maybe this had to do with C++ name mangling but 
it's not compiling the files as C++ because the "extern "C" { } " syntax 
isn't recognized. 
If you are dealing with .cpp files, you do need extern "C" so that names 
of functions are exported in the C way.

I saw a post back in march where someone had to add --export-internal to 
his linking options (on Solaris) in order for the callback symbols to be 
available for libglade to "find".  However I have been unsuccessful in 
determining any similar flag/setting in MSVC++.  Any suggestions?
There're two ways: using a .def file or Microsoft specified __declspec. 
The later one doesn't require you to maintain a separate .def file and 
it's quite simple:

/* foo.h */
#ifndef _FOO_H_
#define _FOO_H_

#include <gtk/gtk.h>

#ifdef G_OS_WIN32
#define GTK_CB __declspec(dllexport)
#else
#define GTK_CB
#endif

#ifdef __cplusplus
extern "C" {
#endif

GTK_CB void example_button_clicked(GtkButton * button, gpointer user_data);

#ifdef __cplusplus
}
#endif

#endif



/* foo.cpp */
#include "foo.h"

void example_button_clicked(GtkButton * button, gpointer user_data)
{
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]