← Back to team overview

kicad-developers team mailing list archive

[PATCH 06/12] Make sure KIFACE_GETTER linkage is consistent

 

This makes sure that the declaration is always the same within a single
module, so all users have the same idea of whether the symbol is imported.

In all dynamically linked objects, all users should be aware that the
symbol is imported, while in the statically linked bitmap2component
program, no import/export decorations should be used.
---
 bitmap2component/bitmap2cmp_gui.cpp |  2 +-
 include/kiway.h                     | 10 +++++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp
index 67651ed..5caa7a6 100644
--- a/bitmap2component/bitmap2cmp_gui.cpp
+++ b/bitmap2component/bitmap2cmp_gui.cpp
@@ -719,7 +719,7 @@ KIFACE_I& Kiface()
 
 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
-MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
+KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
 {
     process = (PGM_BASE*) aProgram;
     return &kiface;
diff --git a/include/kiway.h b/include/kiway.h
index 10340ac..43eafab 100644
--- a/include/kiway.h
+++ b/include/kiway.h
@@ -445,7 +445,15 @@ extern KIWAY Kiway;     // provided by single_top.cpp and kicad.cpp
 typedef     KIFACE*  KIFACE_GETTER_FUNC( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
 
 /// No name mangling.  Each KIFACE (DSO/DLL) will implement this once.
-extern "C" KIFACE* KIFACE_GETTER(  int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+extern "C" {
+
+#if defined(BUILD_KIWAY_DLL)
+MY_API( KIFACE* ) KIFACE_GETTER(  int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+#else
+KIFACE* KIFACE_GETTER(  int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram );
+#endif
+
+}
 
 
 #endif  // KIWAY_H_

Follow ups

References