From: Amos Jeffries Date: Thu, 3 Sep 2009 12:56:47 +0000 (+1200) Subject: Bug 2734: fix compile errors from CBDATA_CLASS2() X-Git-Tag: SQUID_3_0_STABLE19~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1843e0d1438671f34987e8d985a7ff625cfb8cbc;p=thirdparty%2Fsquid.git Bug 2734: fix compile errors from CBDATA_CLASS2() 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. --- diff --git a/src/StoreHashIndex.h b/src/StoreHashIndex.h index a17778d544..a516c7c967 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -110,13 +110,15 @@ public: RefCount sd; private: - CBDATA_CLASS2(StoreSearchHashIndex); void copyBucket(); void (*callback)(void *cbdata); void *cbdata; bool _done; int bucket; Vector entries; + + // keep this last. it plays with private/public + CBDATA_CLASS2(StoreSearchHashIndex); }; #endif /* SQUID_STOREHASHINDEX_H */ diff --git a/src/cbdata.h b/src/cbdata.h index 2d7df90355..ec5506004b 100644 --- a/src/cbdata.h +++ b/src/cbdata.h @@ -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); }; diff --git a/src/forward.h b/src/forward.h index d587c50ce0..a7b011a6c6 100644 --- a/src/forward.h +++ b/src/forward.h @@ -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