Hi Ralf,

Den 2010-07-16 05:36 skrev Ralf Wildenhues:
OK.  The patch is fine with me then.

Good, thanks! I'm swapped "defined PIC" for "defined DLL_EXPORT", so this
is what I pushed:

diff --git a/ChangeLog b/ChangeLog
index a20add4..5c425b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-07-17  Peter Rosin  <p...@lysator.liu.se>
+
+       dllimport the variable for MSVC in link-order.at
+       * tests/link-order.at [MSVC]: Makes the test pass by dllimporting
+       imported variables when working with shared libraries.
+
 2010-07-08  Peter Rosin  <p...@lysator.liu.se>
            Ralf Wildenhues  <ralf.wildenh...@gmx.de>

diff --git a/tests/link-order.at b/tests/link-order.at
index 0122a45..05ce776 100644
--- a/tests/link-order.at
+++ b/tests/link-order.at
@@ -48,13 +48,31 @@ for i in old new; do
   mkdir src

   cat >src/a_$i.c <<EOF
-extern int c;
+/* w32 fun, MSVC needs to dllimport when using a shared library, so use
+ * DLL_EXPORT to discriminate as that happens to coinside in this case.
+ * gnu has auto import.
+ */
+#if defined _MSC_VER && defined DLL_EXPORT
+#  define LIBCEE_SCOPE __declspec(dllimport)
+#else
+#  define LIBCEE_SCOPE extern
+#endif
+LIBCEE_SCOPE int c;
 extern int b_$i();
 int a_$i() { return c + b_$i(); }
 EOF

   cat >src/b_$i.c <<EOF
-extern int c;
+/* w32 fun, MSVC needs to dllimport when using a shared library, so use
+ * DLL_EXPORT to discriminate as that happens to coinside in this case.
+ * gnu has auto import.
+ */
+#if defined _MSC_VER && defined DLL_EXPORT
+#  define LIBCEE_SCOPE __declspec(dllimport)
+#else
+#  define LIBCEE_SCOPE extern
+#endif
+LIBCEE_SCOPE int c;
 int b_$i() { return 1 + c; }
 EOF



OK.  Do we need to remember it somewhere (e.g., in TODO, exept that
this is hopelessly outdated)?

I don't think *I* need a reminder. But documentation isn't written by
itself so I don't know when it will be done...

I didn't think the onus
was on me to write this as it has been a known issue on Windows for a
long time (I was just temporarily fooled that it was a non-issue with
MSVC when I misguidedly thought you could always dllimport with it).

I didn't mean to imply that the onus is on you.  Just that it needs to
be done.

Ok, it is just easy to read too much into your notes. Sorry about that.

The manual already says that it is not portable to export data items from
a libtool library. At least I think it does.

The "Library tips" nodes has a bit.

Hmmm, my memory says that I have read something with the meaning that
exporting variables makes your life difficult on some platforms but I
now fail to find it in the libtool manual. Strange...

Cheers,
Peter

Reply via email to