mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Mingw-w64 build fixes for long long
On mingw-w64, long long (64bit wide) is larger than long (32bit wide). Therefore we need some more specializations for string, docstring, otextstream and << overloaded ostream functions. The configuration code is by me, the source code changes by Shankar Giri Venkita Giri (bug 10053).
This commit is contained in:
parent
e07a01a3c3
commit
d5f2bad461
13
configure.ac
13
configure.ac
@ -130,6 +130,13 @@ LYX_CHECK_CALLSTACK_PRINTING
|
||||
# Needed for our char_type
|
||||
AC_CHECK_SIZEOF(wchar_t)
|
||||
|
||||
# Needed for Mingw-w64
|
||||
AC_TYPE_LONG_LONG_INT
|
||||
if test "$ac_cv_type_long_long_int" = yes; then
|
||||
AC_CHECK_SIZEOF(long)
|
||||
AC_CHECK_SIZEOF(long long)
|
||||
fi
|
||||
|
||||
### We need iconv for unicode support (Qt4 frontend requires it too)
|
||||
AM_ICONV
|
||||
if test "$am_cv_func_iconv" = no; then
|
||||
@ -324,6 +331,12 @@ char * strerror(int n);
|
||||
# define USE_WCHAR_T
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LONG_LONG_INT
|
||||
#if SIZEOF_LONG_LONG > SIZEOF_LONG
|
||||
#define LYX_USE_LONG_LONG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
])
|
||||
|
||||
|
@ -114,6 +114,13 @@ check_cxx_source_compiles(
|
||||
"
|
||||
SIZEOF_WCHAR_T_IS_4)
|
||||
|
||||
check_cxx_source_compiles(
|
||||
"
|
||||
int i[ ( sizeof(long long)>sizeof(long) ? 1 : -1 ) ];
|
||||
int main(){return 0;}
|
||||
"
|
||||
SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG)
|
||||
|
||||
check_cxx_source_compiles(
|
||||
"
|
||||
#include <execinfo.h>
|
||||
|
@ -42,6 +42,7 @@
|
||||
#cmakedefine HAVE_MAGIC_H 1
|
||||
#cmakedefine SIZEOF_WCHAR_T_IS_2 1
|
||||
#cmakedefine SIZEOF_WCHAR_T_IS_4 1
|
||||
#cmakedefine SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG 1
|
||||
|
||||
#ifdef SIZEOF_WCHAR_T_IS_2
|
||||
# define SIZEOF_WCHAR_T 2
|
||||
@ -51,6 +52,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG
|
||||
#define LYX_USE_LONG_LONG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#cmakedefine GETTEXT_FOUND 1
|
||||
|
||||
#cmakedefine HAVE_ALLOCA 1
|
||||
|
@ -152,6 +152,12 @@
|
||||
# define USE_WCHAR_T
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LONG_LONG
|
||||
#ifdef SIZEOF_LONG_LONG_GREATER_THAN_SIZEOF_LONG
|
||||
#define LYX_USE_LONG_LONG
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MAKE_INTL_LIB) && defined(_MSC_VER)
|
||||
#define __attribute__(x)
|
||||
#define inline
|
||||
|
@ -90,6 +90,22 @@ docstring convert<docstring>(unsigned long ul)
|
||||
}
|
||||
|
||||
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<>
|
||||
string convert<string>(unsigned long long ull)
|
||||
{
|
||||
return lexical_cast<string>(ull);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring convert<docstring>(unsigned long long ull)
|
||||
{
|
||||
return from_ascii(lexical_cast<string>(ull));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template<>
|
||||
string convert<string>(long l)
|
||||
{
|
||||
@ -104,6 +120,22 @@ docstring convert<docstring>(long l)
|
||||
}
|
||||
|
||||
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<>
|
||||
string convert<string>(long long ll)
|
||||
{
|
||||
return lexical_cast<string>(ll);
|
||||
}
|
||||
|
||||
|
||||
template<>
|
||||
docstring convert<docstring>(long long ll)
|
||||
{
|
||||
return from_ascii(lexical_cast<string>(ll));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template<>
|
||||
string convert<string>(float f)
|
||||
{
|
||||
|
@ -33,8 +33,16 @@ template<> std::string convert<std::string>(unsigned int ui);
|
||||
template<> docstring convert<docstring>(unsigned int ui);
|
||||
template<> std::string convert<std::string>(unsigned long ul);
|
||||
template<> docstring convert<docstring>(unsigned long ul);
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<> std::string convert<std::string>(unsigned long long ull);
|
||||
template<> docstring convert<docstring>(unsigned long long ull);
|
||||
#endif
|
||||
template<> std::string convert<std::string>(long l);
|
||||
template<> docstring convert<docstring>(long l);
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<> std::string convert<std::string>(long long ll);
|
||||
template<> docstring convert<docstring>(long long ll);
|
||||
#endif
|
||||
template<> std::string convert<std::string>(float f);
|
||||
template<> std::string convert<std::string>(double d);
|
||||
template<> int convert<int>(std::string const & s);
|
||||
|
@ -243,6 +243,12 @@ LyXErr & operator<<(LyXErr & l, long t)
|
||||
{ return toStream(l, t); }
|
||||
LyXErr & operator<<(LyXErr & l, unsigned long t)
|
||||
{ return toStream(l, t); }
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
LyXErr & operator<<(LyXErr & l, long long t)
|
||||
{ return toStream(l, t); }
|
||||
LyXErr & operator<<(LyXErr & l, unsigned long long t)
|
||||
{ return toStream(l, t); }
|
||||
#endif
|
||||
LyXErr & operator<<(LyXErr & l, double t)
|
||||
{ return toStream(l, t); }
|
||||
LyXErr & operator<<(LyXErr & l, string const & t)
|
||||
|
@ -202,6 +202,10 @@ LyXErr & operator<<(LyXErr &, int);
|
||||
LyXErr & operator<<(LyXErr &, unsigned int);
|
||||
LyXErr & operator<<(LyXErr &, long);
|
||||
LyXErr & operator<<(LyXErr &, unsigned long);
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
LyXErr & operator<<(LyXErr &, long long);
|
||||
LyXErr & operator<<(LyXErr &, unsigned long long);
|
||||
#endif
|
||||
LyXErr & operator<<(LyXErr &, double);
|
||||
LyXErr & operator<<(LyXErr &, std::string const &);
|
||||
LyXErr & operator<<(LyXErr &, docstring const &);
|
||||
|
@ -514,7 +514,7 @@ protected:
|
||||
return do_put_helper(oit, b, fill, v);
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_USE_LONG_LONG
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
iter_type
|
||||
do_put(iter_type oit, ios_base & b, char_type fill, long long v) const
|
||||
{
|
||||
@ -675,7 +675,7 @@ protected:
|
||||
return do_get_integer(iit, eit, b, err, v);
|
||||
}
|
||||
|
||||
#ifdef _GLIBCXX_USE_LONG_LONG
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
iter_type
|
||||
do_get(iter_type iit, iter_type eit, ios_base & b,
|
||||
ios_base::iostate & err, long long & v) const
|
||||
|
@ -1437,6 +1437,17 @@ docstring bformat(docstring const & fmt, long arg1)
|
||||
}
|
||||
|
||||
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, long long arg1)
|
||||
{
|
||||
LATTEST(contains(fmt, from_ascii("%1$d")));
|
||||
docstring const str = subst(fmt, from_ascii("%1$d"), convert<docstring>(arg1));
|
||||
return subst(str, from_ascii("%%"), from_ascii("%"));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
template<>
|
||||
docstring bformat(docstring const & fmt, unsigned int arg1)
|
||||
{
|
||||
|
@ -357,6 +357,9 @@ docstring bformat(docstring const & fmt, Arg1, Arg2, Arg3, Arg4);
|
||||
|
||||
template<> docstring bformat(docstring const & fmt, int arg1);
|
||||
template<> docstring bformat(docstring const & fmt, long arg1);
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template<> docstring bformat(docstring const & fmt, long long arg1);
|
||||
#endif
|
||||
template<> docstring bformat(docstring const & fmt, unsigned int arg1);
|
||||
template<> docstring bformat(docstring const & fmt, docstring arg1);
|
||||
template<> docstring bformat(docstring const & fmt, char * arg1);
|
||||
|
@ -215,6 +215,11 @@ template otexrowstream & operator<< <unsigned int>(otexrowstream &,
|
||||
template otexrowstream & operator<< <unsigned long>(otexrowstream &,
|
||||
unsigned long);
|
||||
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template otexrowstream & operator<< <unsigned long long>(otexrowstream &,
|
||||
unsigned long long);
|
||||
#endif
|
||||
|
||||
|
||||
template <typename Type>
|
||||
otexstream & operator<<(otexstream & ots, Type value)
|
||||
@ -230,5 +235,8 @@ template otexstream & operator<< <double>(otexstream &, double);
|
||||
template otexstream & operator<< <int>(otexstream &, int);
|
||||
template otexstream & operator<< <unsigned int>(otexstream &, unsigned int);
|
||||
template otexstream & operator<< <unsigned long>(otexstream &, unsigned long);
|
||||
#ifdef LYX_USE_LONG_LONG
|
||||
template otexstream & operator<< <unsigned long long>(otexstream &, unsigned long long);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user