Wireshark-dev: Re: [Wireshark-dev] [msvc] 'etype_vals' : unknown size
From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 14 Aug 2013 14:07:19 -0700
On Aug 13, 2013, at 9:18 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:

> On Aug 13, 2013, at 8:24 PM, DbdM Tbt <spin.x2k@xxxxxxxxx> wrote:
> 
>> I would like to update I just now used an SVN checkout of wireshark and error C2133 will not anymore occur.
>> I was mistaken. I didn't expect that I needed the updates to other files aside from etypes.h.
>> About my development situation is that my target is the latest release (of which i assume, meant latest 'stable' release).
>> I will try to ask if the higher-ups will agree to using the development version of wireshark.
>> But in the meantime, I will try to update my working copy with any other files needed to be updated (i.e. ws_symbol_export.h was mentioned).
> 
> If by "working copy" you mean your 1.10.1 tree, there are more files for this fix than just ws_symbol_export.h, and in order for us to find what files they are, we'd have to do the work necessary to backport the fixes in question to the 1.10.1 tree.  That might be the right thing to do.

I tried, but the resulting version of TShark crashed when the buildbot ran some capturing tests.

I've attached a patch with the changes.  I have no time to try to figure out what would need to be done, so you're on your own there; note that we don't develop C++ dissectors as part of the project, and don't guarantee that they'll work.

Index: ws_symbol_export.h
===================================================================
--- ws_symbol_export.h	(revision 51352)
+++ ws_symbol_export.h	(revision 51353)
@@ -49,33 +49,96 @@
 
 /* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
 #if defined _WIN32 || defined __CYGWIN__
+  /* Compiling for Windows, so we use the Windows DLL declarations. */
   #ifdef WS_BUILD_DLL
+    /*
+     * Building a DLL; for all definitions, we want dllexport, and
+     * (presumably so source from DLL and source from a program using the
+     * DLL can both include a header that declares APIs and exported data
+     * for the DLL), for declarations, either dllexport or dllimport will
+     * work (they mean the same thing for a declaration when building a DLL).
+     */
     #ifdef __GNUC__
-#define WS_DLL_PUBLIC __attribute__ ((dllexport))
+      /* GCC */
+#define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((dllexport))
     #else /* ! __GNUC__ */
-#define WS_DLL_PUBLIC __declspec(dllexport) /* Note: actually gcc seems to also support this syntax. */
+      /*
+       * Presumably MSVC.
+       * Note: actually gcc seems to also support this syntax.
+       */
+#define WS_DLL_PUBLIC_NOEXTERN __declspec(dllexport)
     #endif /* __GNUC__ */
-  #else
+  #else /* WS_BUILD_DLL */
+    /*
+     * Building a program; we should only see declarations, not definitions,
+     * with WS_DLL_PUBLIC, and they all represent APIs or data imported
+     * from a DLL, so use dllimport.
+     *
+     * For functions, export shouldn't be necessary; for data, it might
+     * be necessary, e.g. if what's declared is an array whose size is
+     * not given in the declaration.
+     */
     #ifdef __GNUC__
-#define WS_DLL_PUBLIC __attribute__ ((dllimport))
+      /* GCC */
+#define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((dllimport))
     #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
-#define WS_DLL_PUBLIC __declspec(dllimport) /* Note: actually gcc seems to also support this syntax. */
+      /*
+       * Presumably MSVC, and we're not building all-static.
+       * Note: actually gcc seems to also support this syntax.
+       */
+#define WS_DLL_PUBLIC_NOEXTERN __declspec(dllimport)
     #else /* ! __GNUC__  && ENABLE_STATIC */
-#define WS_DLL_PUBLIC
+      /*
+       * Presumably MSVC, and we're building all-static, so we're
+       * not building any DLLs.
+       */
+#define WS_DLL_PUBLIC_NOEXTERN
     #endif /* __GNUC__ */
   #endif /* WS_BUILD_DLL */
-  #define WS_DLL_PUBLIC_NOEXTERN WS_DLL_PUBLIC
+
+  /*
+   * Symbols in a DLL are *not* exported unless they're specifically
+   * flagged as exported, so, for a non-static but non-exported
+   * symbol, we don't have to do anything.
+   */
   #define WS_DLL_LOCAL
-#else
+#else /* defined _WIN32 || defined __CYGWIN__ */
+  /*
+   * Compiling for UN*X, where the dllimport and dllexport stuff
+   * is neither necessary nor supported; just specify the
+   * visibility if we have a compiler that claims compatibility
+   * with GCC 4 or later.
+   */
   #if __GNUC__ >= 4
-#define WS_DLL_PUBLIC __attribute__ ((visibility ("default"))) extern
+    /*
+     * Symbols exported from libraries.
+     */
 #define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((visibility ("default")))
+
+    /*
+     * Non-static symbols *not* exported from libraries.
+     */
 #define WS_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
   #else /* ! __GNUC__ >= 4 */
-    #define WS_DLL_PUBLIC
+    /*
+     * We have no way to control visibility.
+     */
     #define WS_DLL_PUBLIC_NOEXTERN
-    #define WS_DLL_LOCAL extern
+    #define WS_DLL_LOCAL
   #endif /* __GNUC__ >= 4 */
 #endif
 
+/*
+ * You *must* use this for exported data *declarations*; if you use
+ * WS_DLL_PUBLIC_NOEXTERN, some compilers, such as MSVC++, will complain
+ * about array definitions with no size.
+ *
+ * You must *not* use this for exported data *definitions*, as that
+ * will, for some compilers, cause warnings about items being initialized
+ * and declared extern.
+ *
+ * Either can be used for exported *function* declarations and definitions.
+ */
+#define WS_DLL_PUBLIC	WS_DLL_PUBLIC_NOEXTERN extern
+
 #endif /* SYMBOL_EXPORT_H */

Property changes on: .
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r50329,50332,50334,50379,50382