From: Amos Jeffries Date: Wed, 2 Sep 2009 13:09:29 +0000 (+1200) Subject: Bug 2734: fix compile errors from CBDATA_CLASS2() X-Git-Tag: SQUID_3_2_0_1~751 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2bf2f902f18d59143609d67910b164ee97874a1;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 b0c5504fa8..bc602a9f14 100644 --- a/src/StoreHashIndex.h +++ b/src/StoreHashIndex.h @@ -108,13 +108,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 5465196794..5a85b08fad 100644 --- a/src/cbdata.h +++ b/src/cbdata.h @@ -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); }; diff --git a/src/forward.h b/src/forward.h index 1e7eedebef..f0d375d9e6 100644 --- a/src/forward.h +++ b/src/forward.h @@ -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 */