]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 2734: fix compile errors from CBDATA_CLASS2()
authorAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Sep 2009 12:56:47 +0000 (00:56 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Thu, 3 Sep 2009 12:56:47 +0000 (00:56 +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 a17778d544fded6c56fb0e824b89a37dc208a711..a516c7c967213cfa808d6f7e82cf5d9a2b4e1e98 100644 (file)
@@ -110,13 +110,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 2d7df90355efb31482f9b2192a6cfa6a9a1a2c53..ec5506004b70b5bb6b7503fa78d73d5ffc6fd525 100644 (file)
@@ -88,7 +88,12 @@ extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, in
 #define cbdataAlloc(type) ((type *)cbdataInternalAlloc(CBDATA_##type))
 #define cbdataFree(var)                do {if (var) {cbdataInternalFree(var); var = NULL;}} while(0)
 #define cbdataReferenceValidDone(var, ptr) cbdataInternalReferenceDoneValid((void **)&(var), (ptr))
+
+/**
+ * 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) { \
@@ -98,8 +103,7 @@ extern cbdata_type cbdataInternalAddType(cbdata_type type, const char *label, in
                } \
                void operator delete (void *address) { \
                  if (address) cbdataInternalFree(address);\
-               } \
-       private:
+               }
 #endif
 #define cbdataReference(var)   (cbdataInternalLock(var), var)
 #define cbdataReferenceDone(var) do {if (var) {cbdataInternalUnlock(var); var = NULL;}} while(0)
@@ -130,7 +134,7 @@ class generic_cbdata
      * - RBC 20060820
      */
     void *data; /* the wrapped data */
-  private:
+
     CBDATA_CLASS2(generic_cbdata);
 };
 
index d587c50ce0ce8e7da8eb92b57f8b29e2017d1df7..a7b011a6c68107cf2e5905f1b0f700ab4a077536 100644 (file)
@@ -82,7 +82,6 @@ public:
     static void abort(void*);
 
 private:
-    CBDATA_CLASS2(FwdState);
     Pointer self;
     ErrorState *err;
     int client_fd;
@@ -111,6 +110,9 @@ unsigned int forward_completed:1;
     struct sockaddr_in src;
 #endif
 
+
+    // NP: keep this last. It plays with private/public
+    CBDATA_CLASS2(FwdState);
 };
 
 #endif