mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-25 05:01:09 +00:00
modules: Fix build on Visual Studio
Visual Studio does not allow decorating functions with '__declspec (dllexport)' if a prototype exists and is not decorated with '__declspec (dllexport)' as well, so we cannot just decorate g_io_module_[load|unload|query] in the various module sources with G_MODULE_EXPORT because the prototypes of these functions have been marked with _GLIB_EXTERN, which equates to 'extern' unless overridden Fix this by overriding _GLIB_EXTERN with the appropriate visibility flag, as we have used to define _GDK_EXTERN. Unfortunately, we can't just use _GDK_EXTERN G_MODULE_EXPORT as they may have not been defined yet for our use Do this across the board for all modules, even if they are not buildable on Visual Studio nor Windows, for consistency's sake.
This commit is contained in:
parent
5535b26395
commit
acd9c12667
16
meson.build
16
meson.build
@ -286,15 +286,19 @@ endif
|
||||
common_cflags = cc.get_supported_arguments(test_cflags)
|
||||
|
||||
# Symbol visibility
|
||||
|
||||
if os_win32
|
||||
visibility_define = '__declspec(dllexport) extern'
|
||||
else
|
||||
visibility_define = '__attribute__((visibility("default"))) extern'
|
||||
endif
|
||||
|
||||
if get_option('default_library') != 'static'
|
||||
cdata.set('_GDK_EXTERN', visibility_define)
|
||||
if os_win32
|
||||
cdata.set('DLL_EXPORT', true)
|
||||
cdata.set('_GDK_EXTERN', '__declspec(dllexport) extern')
|
||||
if cc.get_id() != 'msvc'
|
||||
common_cflags += ['-fvisibility=hidden']
|
||||
endif
|
||||
else
|
||||
cdata.set('_GDK_EXTERN', '__attribute__((visibility("default"))) extern')
|
||||
endif
|
||||
if cc.get_id() != 'msvc'
|
||||
common_cflags += ['-fvisibility=hidden']
|
||||
endif
|
||||
endif
|
||||
|
@ -97,7 +97,6 @@ G_DEFINE_TYPE_EXTENDED (GtkGstMediaFile, gtk_gst_media_file, GTK_TYPE_MEDIA_FILE
|
||||
G_IMPLEMENT_INTERFACE (GDK_TYPE_PAINTABLE,
|
||||
gtk_gst_media_file_paintable_init))
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_load (GIOModule *module)
|
||||
{
|
||||
@ -109,7 +108,6 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
G_GNUC_NORETURN
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
@ -117,7 +115,6 @@ g_io_module_unload (GIOModule *module)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
@ -23,7 +23,11 @@ endif
|
||||
media_subdir = 'gtk-4.0/@0@/media'.format(gtk_binary_version)
|
||||
media_install_dir = join_paths(get_option('libdir'), media_subdir)
|
||||
|
||||
extra_c_args = ['-DGTK_COMPILATION']
|
||||
extra_c_args = [
|
||||
'-DGTK_COMPILATION',
|
||||
'-D_GLIB_EXTERN=@0@'.format(visibility_define),
|
||||
]
|
||||
|
||||
extra_c_args += common_cflags
|
||||
|
||||
if media_backends.contains('ffmpeg')
|
||||
|
@ -103,7 +103,6 @@ void t_goa_account_free (gpointer data);
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE (GtkPrintBackendCloudprint, gtk_print_backend_cloudprint, GTK_TYPE_PRINT_BACKEND)
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_load (GIOModule *module)
|
||||
{
|
||||
@ -119,13 +118,11 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
{
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
@ -236,7 +236,6 @@ static void secrets_service_vanished_cb (GDBusConnec
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendCups, gtk_print_backend_cups, GTK_TYPE_PRINT_BACKEND)
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_load (GIOModule *module)
|
||||
{
|
||||
@ -251,13 +250,11 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
{
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
@ -102,7 +102,6 @@ static GtkPageSetup * file_printer_get_default_page_size (GtkPrinter
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE(GtkPrintBackendFile, gtk_print_backend_file, GTK_TYPE_PRINT_BACKEND)
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_load (GIOModule *module)
|
||||
{
|
||||
@ -116,13 +115,11 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
{
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
@ -83,7 +83,6 @@ static void gtk_print_backend_lpr_print_stream (GtkPrintBacke
|
||||
|
||||
G_DEFINE_DYNAMIC_TYPE (GtkPrintBackendLpr, gtk_print_backend_lpr, GTK_TYPE_PRINT_BACKEND)
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_load (GIOModule *module)
|
||||
{
|
||||
@ -97,13 +96,11 @@ g_io_module_load (GIOModule *module)
|
||||
10);
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
void
|
||||
g_io_module_unload (GIOModule *module)
|
||||
{
|
||||
}
|
||||
|
||||
G_MODULE_EXPORT
|
||||
char **
|
||||
g_io_module_query (void)
|
||||
{
|
||||
|
@ -68,6 +68,7 @@ printbackends_args = [
|
||||
'-DGTK_COMPILATION',
|
||||
'-DGTK_DISABLE_DEPRECATION_WARNINGS',
|
||||
'-DGTK_PRINT_BACKEND_ENABLE_UNSUPPORTED',
|
||||
'-D_GLIB_EXTERN=@0@'.format(visibility_define),
|
||||
] + common_cflags
|
||||
|
||||
if print_backends.contains('cups')
|
||||
|
Loading…
Reference in New Issue
Block a user