[Click] Build fix for etherswitch.cc [PATCH ATTACHED]

Eddie Kohler kohler at cs.ucla.edu
Mon Apr 3 11:40:05 EDT 2006


Michael,

Thanks for the bug report!  This error is in fact a little bogus on the part 
of the compiler, since the HashMap<...>::Elt object that it complains about is 
never constructed.  So I'd rather not add your fix.  I've checked in the below 
diff, can you report whether it works for you?

THanks,
Eddie



Index: include/click/bighashmap.hh
===================================================================
RCS file: /home/am0/click/cvsroot/release/one/include/click/bighashmap.hh,v
retrieving revision 1.26
diff -u -u -r1.26 bighashmap.hh
--- include/click/bighashmap.hh 1 Apr 2006 02:44:48 -0000       1.26
+++ include/click/bighashmap.hh 3 Apr 2006 15:37:33 -0000
@@ -79,9 +79,13 @@

   private:

-  struct Elt : public Pair {
-    Elt *next;
-  };
+    struct Elt : public Pair {
+       Elt *next;
+#if defined(__GNUC__) && __GNUC__ < 4
+       /* Shut up compiler about Pair lacking default constructor */
+       Elt(const Pair &p)              : Pair(p) { }
+#endif
+    };

    Elt **_buckets;
    int _nbuckets;
@@ -262,11 +266,15 @@
          DEFAULT_INITIAL_NBUCKETS = 127,
          DEFAULT_RESIZE_THRESHOLD = 2 };

- private:
+  private:

-  struct Elt : public Pair {
-    Elt *next;
-  };
+    struct Elt : public Pair {
+       Elt *next;
+#if defined(__GNUC__) && __GNUC__ < 4
+       /* Shut up compiler about Pair lacking default constructor */
+       Elt(const Pair &p)              : Pair(p) { }
+#endif
+    };

    Elt **_buckets;
    int _nbuckets;





Michael Gellman wrote:
> On compiling the latest CVS version of Click on Fedora Core 2, I
> received the following error:
> 
> In file included from ../include/click/straccum.hh:210,
>                  from ../include/click/straccum.hh:248,
>                  from ../elements/etherswitch/etherswitch.cc:210:
> ../include/click/bighashmap.hh: In instantiation of `HashMap<EtherAddress,
> EtherSwitch::AddrInfo>::Elt':
> ../include/click/bighashmap.hh:112:   instantiated from `const K&
> _HashMap_const_iterator<K, V>::key() const [with K = EtherAddress, V =
> EtherSwitch::AddrInfo]'
> ../include/click/straccum.hh:207:   instantiated from here
> ../include/click/bighashmap.hh:82: error: base `HashMap<EtherAddress,
>    EtherSwitch::AddrInfo>::Pair' with only non-default constructor in class
>    without a constructor
> 
> I believe the attached patch, which adds a default constructor to the
> AddrInfo struct, corrects the error.
> 
> Michael Gellman
> --
> Intelligent Systems & Networks Group
> Dept of Electrical & Electronic Engineering
> Imperial College London
> London SW7 2BT
> 
> --- click-1.5cvs/elements/etherswitch/etherswitch.hh    2006-03-06
> 11:28:42.825077168 +0000
> +++ click-working/elements/etherswitch/etherswitch.hh   2006-03-06
> 12:39:56.977307264 +0000
> @@ -78,6 +78,7 @@
>         int port;
>         Timestamp stamp;
>         inline AddrInfo(int p, const Timestamp &t);
> +       inline AddrInfo();
>      };
> 
>    private:
> @@ -95,6 +96,12 @@
>  };
> 
>  inline
> +EtherSwitch::AddrInfo::AddrInfo()
> +    : port(0), stamp(Timestamp(0))
> +{
> +}
> +
> +inline
>  EtherSwitch::AddrInfo::AddrInfo(int p, const Timestamp& s)
>      : port(p), stamp(s)
>  {
> _______________________________________________
> click mailing list
> click at amsterdam.lcs.mit.edu
> https://amsterdam.lcs.mit.edu/mailman/listinfo/click


More information about the click mailing list