]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2734: fix compile errors from CBDATA_CLASS2()
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 2 Sep 2009 13:09:29 +0000 (01:09 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 2 Sep 2009 13:09:29 +0000 (01:09 +1200)
Some compilers don't like the sytax private:;

This makes the starting state explicitly private: instead of assuming its
going to be defined in a private state and dependign on the definer class.

We can cope with not setting the state to private at the end of the macro
as well. It just means the use of this macro must be last, or have an
explicit private/public definition after its use.

src/StoreHashIndex.h
src/cbdata.h
src/forward.h

index b0c5504fa8eaea3f308d523250c872e7a21a3dfe..bc602a9f142532db859267fe36291381f2e90117 100644 (file)
@@ -108,13 +108,15 @@ public:
     RefCount<StoreHashIndex> sd;
 
 private:
-    CBDATA_CLASS2(StoreSearchHashIndex);
     void copyBucket();
     void (*callback)(void *cbdata);
     void *cbdata;
     bool _done;
     int bucket;
     Vector<StoreEntry *> entries;
+
+    // keep this last. it plays with private/public
+    CBDATA_CLASS2(StoreSearchHashIndex);
 };
 
 #endif /* SQUID_STOREHASHINDEX_H */
index 5465196794ed7305bc763098daf5a89d77daf09d..5a85b08fadbae2e316182a96f54f28bad8540d1a 100644 (file)
@@ -334,8 +334,13 @@ extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, in
  */
 #define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr))
 
-/// \ingroup CBDATAAPI
+/**
+ * \ingroup CBDATAAPI
+ * 
+ * This needs to be defined LAST in teh class definition. It plays with private/public states in C++.
+ */
 #define CBDATA_CLASS2(type)    \
+       private: \
        static cbdata_type CBDATA_##type; \
        public: \
                void *operator new(size_t size) { \
@@ -346,8 +351,7 @@ extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, in
                void operator delete (void *address) { \
                  if (address) cbdataInternalFree(address);\
                } \
-                void *toCbdata() { return this; } \
-       private:
+                void *toCbdata() { return this; }
 #endif /* !CBDATA_DEBUG */
 
 /**
@@ -459,6 +463,7 @@ public:
      \todo CODE: make this a private field.
      */
     void *data; /* the wrapped data */
+
 private:
     CBDATA_CLASS2(generic_cbdata);
 };
index 1e7eedebef4f346e5be5f5e98cd517d749b051f3..f0d375d9e6d46479af52c1ab6d67ba4e766ad842 100644 (file)
@@ -81,7 +81,6 @@ public:
     static void abort(void*);
 
 private:
-    CBDATA_CLASS2(FwdState);
     Pointer self;
     ErrorState *err;
     int client_fd;
@@ -100,6 +99,9 @@ private:
     } flags;
 
     IpAddress src; /* Client address for this connection. Needed for transparent operations. */
+
+    // NP: keep this last. It plays with private/public
+    CBDATA_CLASS2(FwdState);
 };
 
 #endif /* SQUID_FORWARD_H */