forked from enlightenment/efl
efl_canvas_wl: Rename EAPI macro to EFL_CANVAS_WL_API in Efl Canvas WL library
Patch from a series of patches to rename EAPI symbols to specific library DSOs. EAPI was designed to be able to pass ```__attribute__ ((visibility ("default")))``` for symbols with GCC, which would mean that even if -fvisibility=hidden was used when compiling the library, the needed symbols would get exported. MSVC __almost__ works like GCC (or mingw) in which you can declare everything as export and it will just work (slower, but it will work). But there's a caveat: global variables will not work the same way for MSVC, but works for mingw and GCC. For global variables (as opposed to functions), MSVC requires correct DSO visibility for MSVC: instead of declaring a symbol as export for everything, you need to declare it as import when importing from another DSO and export when defining it locally. With current EAPI definitions, we get the following example working in mingw and MSVC (observe it doesn't define any global variables as exported symbols). Example 1: dll1: ``` EAPI void foo(void); EAPI void bar() { foo(); } ``` dll2: ``` EAPI void foo() { printf ("foo\n"); } ``` This works fine with API defined as __declspec(dllexport) in both cases and for gcc defining as ```__atttribute__((visibility("default")))```. However, the following: Example 2: dll1: ``` EAPI extern int foo; EAPI void foobar(void); EAPI void bar() { foo = 5; foobar(); } ``` dll2: ``` EAPI int foo = 0; EAPI void foobar() { printf ("foo %d\n", foo); } ``` This will work on mingw but will not work for MSVC. And that's why EAPI is the only solution that worked for MSVC. Co-authored-by: João Paulo Taylor Ienczak Zanette <jpaulotiz@gmail.com> Co-authored-by: Ricardo Campos <ricardo.campos@expertise.dev> Co-authored-by: Lucas Cavalcante de Sousa <lucks.sousa@gmail.com>
This commit is contained in:
parent
64719a4116
commit
dc775bf8cb
|
@ -3,24 +3,7 @@
|
|||
#include <Evas.h>
|
||||
#include <Efl_Core.h>
|
||||
|
||||
#ifdef EAPI
|
||||
# undef EAPI
|
||||
#endif
|
||||
#ifdef EAPI_WEAK
|
||||
# undef EAPI_WEAK
|
||||
#endif
|
||||
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# define EAPI_WEAK
|
||||
# else
|
||||
# define EAPI
|
||||
# define EAPI_WEAK
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#define EWAPI EAPI EAPI_WEAK
|
||||
#include <efl_canvas_wl_api.h>
|
||||
|
||||
#ifdef WAYLAND_UTIL_H
|
||||
typedef struct wl_surface Efl_Canvas_Wl_Wl_Surface;
|
||||
|
@ -53,9 +36,5 @@ typedef struct Efl_Canvas_Wl_Xkb_State Efl_Canvas_Wl_Xkb_State;
|
|||
* @return The Evas_Object of the surface, NULL on failure
|
||||
* @since 1.24
|
||||
*/
|
||||
EAPI Evas_Object *efl_canvas_wl_extracted_surface_object_find(void *surface_resource);
|
||||
#undef EAPI
|
||||
#define EAPI
|
||||
#undef EAPI_WEAK
|
||||
#define EAPI_WEAK
|
||||
EFL_CANVAS_WL_API Evas_Object *efl_canvas_wl_extracted_surface_object_find(void *surface_resource);
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef _EFL_EFL_CANVAS_WL_API_H
|
||||
#define _EFL_EFL_CANVAS_WL_API_H
|
||||
|
||||
#ifdef EFL_CANVAS_WL_API
|
||||
#error EFL_CANVAS_WL_API should not be already defined
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef EFL_CANVAS_WL_STATIC
|
||||
# ifdef EFL_CANVAS_WL_BUILD
|
||||
# define EFL_CANVAS_WL_API __declspec(dllexport)
|
||||
# else
|
||||
# define EFL_CANVAS_WL_API __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define EFL_CANVAS_WL_API
|
||||
# endif
|
||||
# define EFL_CANVAS_WL_API_WEAK
|
||||
#else
|
||||
# ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EFL_CANVAS_WL_API __attribute__ ((visibility("default")))
|
||||
# define EFL_CANVAS_WL_API_WEAK __attribute__ ((weak))
|
||||
# else
|
||||
# define EFL_CANVAS_WL_API
|
||||
# define EFL_CANVAS_WL_API_WEAK
|
||||
# endif
|
||||
# else
|
||||
# define EFL_CANVAS_WL_API
|
||||
# define EFL_CANVAS_WL_API_WEAK
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@ foreach eo_file : pub_eo_files
|
|||
'-o', 'h:' + join_paths(meson.current_build_dir(), eo_file + '.h'),
|
||||
'-o', 'c:' + join_paths(meson.current_build_dir(), eo_file + '.c'),
|
||||
'-o', 'd:' + join_paths(meson.current_build_dir(), eo_file + '.d'),
|
||||
'-e', 'EFL_CANVAS_WL_API',
|
||||
'-gchd', '@INPUT@'])
|
||||
endforeach
|
||||
|
||||
|
@ -31,7 +32,7 @@ efl_canvas_wl_src = files([
|
|||
'efl_canvas_wl.c',
|
||||
])
|
||||
|
||||
efl_canvas_wl_header_src = ['Efl_Canvas_Wl.h']
|
||||
efl_canvas_wl_header_src = ['Efl_Canvas_Wl.h', 'efl_canvas_wl_api.h']
|
||||
eolian_include_directories += ['-I', meson.current_source_dir()]
|
||||
|
||||
efl_canvas_wl_lib = library('efl_canvas_wl',
|
||||
|
|
Loading…
Reference in New Issue