[dia] [clang-cl] Improved DIAVAR handling



commit 1396e6920811871504f8886110fad38d7e5eddba
Author: Hans Breuer <hans breuer org>
Date:   Sat Dec 14 12:39:40 2013 +0100

    [clang-cl] Improved DIAVAR handling
    
    While compiling Dia with clang-cl [1] there was a problem with multiple
    definitions of variables declared with DIAVAR. Apparently the MS compiler
    is more forgiving with inclusion of '__declspec(dllexport) Type name;'
    in multiple translation units. clang-cl was producing colliding symbols
    in different obj files. The implemented fix is treating DIAVAR and the
    extern keyword as orthogonal concepts. So for a global variable the
    declaration is 'extern DIAVAR SomeType name;' while the instantiation
    is just 'DIAVAR SomeType name;'.
    This also fixes a gcc complaint about an external variable being
    initialized (in units.c).
    Of course the best way to handle global variables is to get rid of them
    altogether.
    
    [1] http://blog.llvm.org/2013/11/the-clang-cl-fallback-mode.html

 lib/diavar.h       |   12 ++++++------
 lib/group.h        |    2 +-
 lib/units.h        |    2 +-
 tests/makefile.msc |    5 +++--
 4 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/lib/diavar.h b/lib/diavar.h
index a1b7d67..a7f3b53 100644
--- a/lib/diavar.h
+++ b/lib/diavar.h
@@ -7,14 +7,14 @@
 #  ifdef LIBDIA_COMPILATION
 #    define DIAVAR __declspec(dllexport)
 #  else  /* !LIBDIA_COMPILATION */
-#    define DIAVAR extern __declspec(dllimport)
+#    define DIAVAR __declspec(dllimport)
 #  endif /* !LIBDIA_COMPILATION */
 #else  /* !G_OS_WIN32 */
-#  define DIAVAR extern
+#  /* DONT: define DIAVAR extern */
+#  /* extern and __declspec() are orthogonal - otherwise there wont be a difference between
+#   * the header declared variable and the one defined in the implmentation. At least clang-cl
+#   * code generation would create mutliple definitions, which later prohibit linking.
+#   */
 #endif
 
-/*! bounding box debug helper : set to !0 to see the caclulated bounding boxes */
-DIAVAR int render_bounding_boxes;
-
-
 #endif
diff --git a/lib/group.h b/lib/group.h
index 101f187..2857358 100644
--- a/lib/group.h
+++ b/lib/group.h
@@ -21,7 +21,7 @@
 #include "diavar.h"
 #include "object.h"
 
-DIAVAR DiaObjectType group_type;
+extern DIAVAR DiaObjectType group_type;
 
 /* Make sure there are no connections from objects to objects
  * outside of the created group before calling group_create().
diff --git a/lib/units.h b/lib/units.h
index 93bf8a9..49f1db6 100644
--- a/lib/units.h
+++ b/lib/units.h
@@ -40,6 +40,6 @@ struct _DiaUnitDef {
   int digits; /** Number of digits after the decimal separator */
 };
 
-const DIAVAR DiaUnitDef units[];
+extern const DIAVAR DiaUnitDef units[];
 
 #endif /* UNITS_H */
diff --git a/tests/makefile.msc b/tests/makefile.msc
index 8108ff3..f3ae16d 100644
--- a/tests/makefile.msc
+++ b/tests/makefile.msc
@@ -14,8 +14,9 @@ DEFINES = -DHAVE_CONFIG_H
 
 TESTS = \
        test-boundingbox.exe \
+       test-sizeof.exe \
+       test-svg.exe \
        test-objects.exe \
-       test-sizeof.exe
 
 all :  $(TESTS)
 
@@ -24,7 +25,7 @@ all : $(TESTS)
        $(CC) $(CFLAGS) -Fe$@ $< ..\lib\libdia.lib $(GLIB_LIBS) $(LDFLAGS) user32.lib /subsystem:console
 
 check: all
-       for %p in ($(TESTS)) do set PATH=..\lib;%PATH% && %p ..\objects\UML\\
+       for %p in ($(TESTS)) do set PATH=..\lib;%PATH% && %p ..\objects\\ -s "/Dia/Objects/Demo, Custom Lines 
- Flow - Bezierline"
 
 test: all
        for %p in ($(TESTS)) do set PATH=..\lib;%PATH% && %p ..\objects\\


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