Peter Kümmel wrote: > Seems we have to use a ifdef. Or we solve it with help of overloading the casting operator:
Index: src/support/unicode.C =================================================================== --- src/support/unicode.C (revision 14663) +++ src/support/unicode.C (working copy) @@ -14,6 +14,8 @@ #include "unicode.h" +#include <iconv.h> + #include "debug.h" #include <cerrno> @@ -23,6 +25,18 @@ using std::endl; using std::string; + +template<class T> +struct optional_p2p_const_cast +{ + optional_p2p_const_cast(T const ** p2p) : t_p2p(p2p) {} + operator T const **() { return t_p2p; } + operator T **() { return const_cast<T **>(t_p2p); } +private: + T const ** t_p2p; +}; + + namespace { std::vector<char> @@ -45,14 +59,19 @@ } } - char * inbuf = const_cast<char *>(&buf[0]); + char const * inbuf = &buf[0]; size_t inbytesleft = buf.size(); char out[1000] = { 0 }; char * outbuf = out; size_t outbytesleft = 1000; - size_t res = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft); + + // demonstration code only! + optional_p2p_const_cast<char> op2p(&inbuf); + char ** cp2p = op2p; + char const ** p2p = op2p; + size_t res = iconv(cd, optional_p2p_const_cast<char>(&inbuf), &inbytesleft, &outbuf, &outbytesleft); + if (res == (size_t)(-1)) { lyxerr << "Error returned from iconv" << endl; switch (errno) { @@ -108,6 +127,7 @@ { //lyxerr << "Outbuf =" << std::hex; + using boost::uint32_t; std::vector<uint32_t> ucs4; for (size_t i = 0; i < bytes.size(); i += 4) { unsigned char const b1 = bytes[i ]; Then we don't need any macros or change the configure process! Peter