Author: wrowe
Date: Mon Jan 30 13:06:21 2006
New Revision: 373590
URL: http://svn.apache.org/viewcvs?rev=373590&view=rev
Log:
After careful consideration, I believe this resolves the abuse
of the C++ reserved word 'const_cast';
1. replace const_cast with APR_LDAP_UNCONST() which describes
the true results when compiling under v2/MS ldap toolkits.
2. add MS to the 'special exceptions' - their ldap v3 symbols
weren't const, causing about 20 compile warnings of httpd.
3. add doxygenation.
4. preserve const_cast for compatibility with httpd 2.0.55 and
prior, only in the non-C++ world. Compilation failed within
the C++ world anyways.
Modified:
apr/apr-util/branches/0.9.x/include/apr_ldap.h.in
apr/apr-util/branches/0.9.x/include/apr_ldap.hnw
apr/apr-util/branches/0.9.x/include/apr_ldap.hw
Modified: apr/apr-util/branches/0.9.x/include/apr_ldap.h.in
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/0.9.x/include/apr_ldap.h.in?rev=373590&r1=373589&r2=373590&view=diff
==============================================================================
--- apr/apr-util/branches/0.9.x/include/apr_ldap.h.in (original)
+++ apr/apr-util/branches/0.9.x/include/apr_ldap.h.in Mon Jan 30 13:06:21 2006
@@ -127,16 +127,33 @@
@ldap_h@
#endif
-/* LDAPv2 SDKs don't use const parameters in their prototypes.
- * LDAPv3 SDKs do use const. When compiling with LDAPv2 SDKs, const_cast
- * casts away the constness, but won't under LDAPv3
+/* MS & v2 LDAP SDKs don't use const parameters in their prototypes,
+ * LDAPv3 SDKs mostly use const. Bridge the gap for clean compilation.
*/
-#if LDAP_VERSION_MAX <= 2
-#define const_cast(x) ((char *)(x))
+
+#if LDAP_VERSION_MAX <= 2 || APR_HAS_MICROSOFT_LDAPSDK || defined(DOXYGEN)
+/**
+ * Cast away constness to compile cleanly against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
+ */
+#define APR_LDAP_UNCONST(conststr) ((char *)(conststr))
#else
-#define const_cast(x) (x)
-#endif
+#define APR_LDAP_UNCONST(conststr) (conststr)
+#endif
+#ifndef __cplusplus
+/**
+ * Cast away constness to compile against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
+ * @bug The apr_ldap.h macro const_cast violated three rules;
+ * it was a C++ reserved keyword, it violated the uppercase-only
+ * style guideline for apr macros, and it was not namespace protected.
+ * It exists here soley to avoid breaking legacy sources using APR 0.9.
+ * @deprecated @see APR_LDAP_UNCONST
+ */
+#define const_cast(conststr) APR_LDAP_UNCONST(conststr)
+#endif
+
#include "apr_ldap_url.h"
/* Define some errors that are mysteriously gone from OpenLDAP 2.x */
Modified: apr/apr-util/branches/0.9.x/include/apr_ldap.hnw
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/0.9.x/include/apr_ldap.hnw?rev=373590&r1=373589&r2=373590&view=diff
==============================================================================
--- apr/apr-util/branches/0.9.x/include/apr_ldap.hnw (original)
+++ apr/apr-util/branches/0.9.x/include/apr_ldap.hnw Mon Jan 30 13:06:21 2006
@@ -125,18 +125,33 @@
#define LDAPS_PORT LDAP_SSL_PORT
#endif
+/* MS & v2 LDAP SDKs don't use const parameters in their prototypes,
+ * LDAPv3 SDKs mostly use const. Bridge the gap for clean compilation.
+ */
-/* LDAPv2 SDKs don't use const parameters in their prototypes.
- * LDAPv3 SDKs do use const. When compiling with LDAPv2 SDKs, const_cast
- * casts away the constness, but won't under LDAPv3
+#if LDAP_VERSION_MAX <= 2 || APR_HAS_MICROSOFT_LDAPSDK || defined(DOXYGEN)
+/**
+ * Cast away constness to compile cleanly against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
*/
-#if LDAP_VERSION_MAX <= 2
-#define const_cast(x) ((char *)(x))
+#define APR_LDAP_UNCONST(conststr) ((char *)(conststr))
#else
-#define const_cast(x) (x)
+#define APR_LDAP_UNCONST(conststr) (conststr)
#endif
-
+#ifndef __cplusplus
+/**
+ * Cast away constness to compile against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
+ * @bug The apr_ldap.h macro const_cast violated three rules;
+ * it was a C++ reserved keyword, it violated the uppercase-only
+ * style guideline for apr macros, and it was not namespace protected.
+ * It exists here soley to avoid breaking legacy sources using APR 0.9.
+ * @deprecated @see APR_LDAP_UNCONST
+ */
+#define const_cast(conststr) APR_LDAP_UNCONST(conststr)
+#endif
+
#include "apr_ldap_url.h"
/* Define some errors that are mysteriously gone from OpenLDAP 2.x */
Modified: apr/apr-util/branches/0.9.x/include/apr_ldap.hw
URL: http://svn.apache.org/viewcvs/apr/apr-util/branches/0.9.x/include/apr_ldap.hw?rev=373590&r1=373589&r2=373590&view=diff
==============================================================================
--- apr/apr-util/branches/0.9.x/include/apr_ldap.hw (original)
+++ apr/apr-util/branches/0.9.x/include/apr_ldap.hw Mon Jan 30 13:06:21 2006
@@ -128,17 +128,32 @@
#define LDAPS_PORT LDAP_SSL_PORT
#endif
+/* MS & v2 LDAP SDKs don't use const parameters in their prototypes,
+ * LDAPv3 SDKs mostly use const. Bridge the gap for clean compilation.
+ */
-/* LDAPv2 SDKs don't use const parameters in their prototypes.
- * LDAPv3 SDKs do use const. When compiling with LDAPv2 SDKs, const_cast
- * casts away the constness, but won't under LDAPv3
+#if LDAP_VERSION_MAX <= 2 || APR_HAS_MICROSOFT_LDAPSDK || defined(DOXYGEN)
+/**
+ * Cast away constness to compile cleanly against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
*/
-#if LDAP_VERSION_MAX <= 2
-#define const_cast(x) ((char *)(x))
+#define APR_LDAP_UNCONST(conststr) ((char *)(conststr))
#else
-#define const_cast(x) (x)
+#define APR_LDAP_UNCONST(conststr) (conststr)
+#endif
+
+#ifndef __cplusplus
+/**
+ * Cast away constness to compile against v2 and MS LDAP SDKs
+ * @param conststr The value to un-constify on older LDAP SDKs
+ * @bug The apr_ldap.h macro const_cast violated three rules;
+ * it was a C++ reserved keyword, it violated the uppercase-only
+ * style guideline for apr macros, and it was not namespace protected.
+ * It exists here soley to avoid breaking legacy sources using APR 0.9.
+ * @deprecated @see APR_LDAP_UNCONST
+ */
+#define const_cast(conststr) APR_LDAP_UNCONST(conststr)
#endif
-
#include "apr_ldap_url.h"
|