added wxLL and wxLongLongFmtSpec macros; documented them; added a test in the sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@17507 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -153,6 +153,8 @@ the corresponding topic.
|
||||
\helpref{wxLogTrace}{wxlogtrace}\\
|
||||
\helpref{wxLogVerbose}{wxlogverbose}\\
|
||||
\helpref{wxLogWarning}{wxlogwarning}\\
|
||||
\helpref{wxLL}{wxll}\\
|
||||
\helpref{wxLongLongFmtSpec}{wxlonglongfmtspec}\\
|
||||
\helpref{wxMakeMetafilePlaceable}{wxmakemetafileplaceable}\\
|
||||
\helpref{wxMatchWild}{wxmatchwild}\\
|
||||
\helpref{wxMessageBox}{wxmessagebox}\\
|
||||
@@ -2109,6 +2111,44 @@ the compiler supports it or nothing otherwise. Thus, it can be used even in the
|
||||
code which might have to be compiled with an old compiler without support for
|
||||
this language feature but still take advantage of it when it is available.
|
||||
|
||||
\membersection{wxLL}\label{wxll}
|
||||
|
||||
\func{wxLongLong\_t}{wxLL}{\param{}{number}}
|
||||
|
||||
This macro is defined for the platforms with a native 64 bit integer type and
|
||||
allows to define 64 bit compile time constants:
|
||||
|
||||
\begin{verbatim}
|
||||
#ifdef wxLongLong\_t
|
||||
wxLongLong\_t ll = wxLL(0x1234567890abcdef);
|
||||
#endif
|
||||
\end{verbatim}
|
||||
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/longlong.h>
|
||||
|
||||
\membersection{wxLongLongFmtSpec}\label{wxlonglongfmtspec}
|
||||
|
||||
This macro is defined to contain the {\tt printf()} format specifier using
|
||||
which 64 bit integer numbers (i.e. those of type {\tt wxLongLong\_t}) can be
|
||||
printed. Example of using it:
|
||||
|
||||
\begin{verbatim}
|
||||
#ifdef wxLongLong\_t
|
||||
wxLongLong\_t ll = wxLL(0x1234567890abcdef);
|
||||
printf("Long long = %" wxLongLongFmtSpec "x\n", ll);
|
||||
#endif
|
||||
\end{verbatim}
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{wxLL}{wxll}
|
||||
|
||||
\wxheading{Include files}
|
||||
|
||||
<wx/longlong.h>
|
||||
|
||||
\membersection{::wxNewId}\label{wxnewid}
|
||||
|
||||
\func{long}{wxNewId}{\void}
|
||||
|
@@ -25,10 +25,16 @@ also has operators for implicit construction from and conversion to the native
|
||||
|
||||
You would usually use this type in exactly the same manner as any other
|
||||
(built-in) arithmetic type. Note that wxLongLong is a signed type, if you
|
||||
want unsigned values use wxULongLong.
|
||||
want unsigned values use wxULongLong which has exactly the same API as
|
||||
wxLongLong except when explicitly mentioned otherwise.
|
||||
|
||||
If a native (i.e. supported directly by the compiler) 64 bit integer type was
|
||||
found a typedef {\it wxLongLong\_t} will be defined to correspond it.
|
||||
found to exist, {\it wxLongLong\_t} macro will be defined to correspond to it.
|
||||
Also, in this case only, two additional macros will be defined:
|
||||
\helpref{wxLongLongFmtSpec}{wxlonglongfmtspec} for printing 64 bit integers
|
||||
using the standard {\tt printf()} function (but see also
|
||||
\helpref{ToString()}{wxlonglongtostring} for a more portable solution) and
|
||||
\helpref{wxLL}{wxll} for defining 64 bit integer compile-time constants.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
|
@@ -50,15 +50,25 @@
|
||||
// long", then check for specific compilers
|
||||
#if defined(SIZEOF_LONG) && (SIZEOF_LONG == 8)
|
||||
#define wxLongLong_t long
|
||||
#define wxLongLongSuffix l
|
||||
#define wxLongLongFmtSpec _T("l")
|
||||
#define wxLongLongIsLong
|
||||
#elif (defined(__VISUALC__) && defined(__WIN32__)) || defined( __VMS__ )
|
||||
#define wxLongLong_t __int64
|
||||
#define wxLongLongSuffix i64
|
||||
#define wxLongLongFmtSpec _T("I64")
|
||||
#elif defined(__BORLANDC__) && defined(__WIN32__) && (__BORLANDC__ >= 0x520)
|
||||
#define wxLongLong_t __int64
|
||||
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8
|
||||
#define wxLongLong_t long long
|
||||
#elif defined(__MINGW32__) || defined(__CYGWIN__) || defined(__WXMICROWIN__)
|
||||
#define wxLongLongSuffix i64
|
||||
#define wxLongLongFmtSpec _T("I64")
|
||||
#elif (defined(SIZEOF_LONG_LONG) && SIZEOF_LONG_LONG >= 8) || \
|
||||
defined(__MINGW32__) || \\
|
||||
defined(__CYGWIN__) || \\
|
||||
defined(__WXMICROWIN__) \\
|
||||
(defined(__DJGPP__) && __DJGPP__ >= 2)
|
||||
#define wxLongLong_t long long
|
||||
#define wxLongLongSuffix ll
|
||||
#define wxLongLongFmtSpec _T("ll")
|
||||
#elif defined(__MWERKS__)
|
||||
#if __option(longlong)
|
||||
#define wxLongLong_t long long
|
||||
@@ -67,12 +77,10 @@
|
||||
#error "See the documentation on the 'longlong' pragma."
|
||||
#endif
|
||||
#elif defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
||||
#define wxLongLong_t long long
|
||||
#elif defined(__DJGPP__) && __DJGPP__ >= 2
|
||||
#define wxLongLong_t long long
|
||||
#else // no native long long type
|
||||
// both warning and pragma warning are not portable, but at least an
|
||||
// unknown pragma should never be an error - except that, actually, some
|
||||
// unknown pragma should never be an error -- except that, actually, some
|
||||
// broken compilers don't like it, so we have to disable it in this case
|
||||
// <sigh>
|
||||
#if !(defined(__WATCOMC__) || defined(__VISAGECPP__))
|
||||
@@ -85,6 +93,11 @@
|
||||
#define wxUSE_LONGLONG_WX 1
|
||||
#endif // compiler
|
||||
|
||||
// this macro allows to definea 64 bit constant in a portable way
|
||||
#define wxMakeLongLong(x, s) x ## s
|
||||
#define wxMakeLongLong2(x, s) wxMakeLongLong(x, s)
|
||||
#define wxLL(x) wxMakeLongLong2(x, wxLongLongSuffix)
|
||||
|
||||
// the user may predefine wxUSE_LONGLONG_NATIVE and/or wxUSE_LONGLONG_NATIVE
|
||||
// to disable automatic testing (useful for the test program which defines
|
||||
// both classes) but by default we only use one class
|
||||
|
@@ -93,7 +93,7 @@
|
||||
#undef TEST_ALL
|
||||
static const bool TEST_ALL = TRUE;
|
||||
#else
|
||||
#define TEST_WCHAR
|
||||
#define TEST_LONGLONG
|
||||
|
||||
static const bool TEST_ALL = FALSE;
|
||||
#endif
|
||||
@@ -2169,9 +2169,9 @@ static void TestLongLongComparison()
|
||||
#endif // wxUSE_LONGLONG_WX
|
||||
}
|
||||
|
||||
static void TestLongLongPrint()
|
||||
static void TestLongLongToString()
|
||||
{
|
||||
wxPuts(_T("*** Testing wxLongLong printing ***\n"));
|
||||
wxPuts(_T("*** Testing wxLongLong::ToString() ***\n"));
|
||||
|
||||
for ( size_t n = 0; n < WXSIZEOF(testLongs); n++ )
|
||||
{
|
||||
@@ -2186,6 +2186,20 @@ static void TestLongLongPrint()
|
||||
wxPrintf(_T("-0x1234567887654321 = %s\n"), ll.ToString().c_str());
|
||||
}
|
||||
|
||||
static void TestLongLongPrintf()
|
||||
{
|
||||
wxPuts(_T("*** Testing wxLongLong printing ***\n"));
|
||||
|
||||
#ifdef wxLongLongFmtSpec
|
||||
wxLongLong ll = wxLL(0x1234567890abcdef);
|
||||
wxString s = wxString::Format(_T("%") wxLongLongFmtSpec _T("x"), ll);
|
||||
wxPrintf(_T("0x1234567890abcdef -> %s (%s)\n"),
|
||||
s.c_str(), s == _T("1234567890abcdef") ? _T("ok") : _T("ERROR"));
|
||||
#else // !wxLongLongFmtSpec
|
||||
#error "wxLongLongFmtSpec not defined for this compiler/platform"
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef MAKE_LL
|
||||
#undef RAND_LL
|
||||
|
||||
@@ -2713,7 +2727,7 @@ I am ready for my first lesson today.");
|
||||
{
|
||||
wxChar buf[200];
|
||||
|
||||
wxSprintf (buf, _T("%07Lo"), (wxLongLong_t)040000000000ll);
|
||||
wxSprintf(buf, _T("%07") wxLongLongFmtSpec _T("o"), wxLL(040000000000));
|
||||
wxPrintf (_T("sprintf (buf, \"%%07Lo\", 040000000000ll) = %s"), buf);
|
||||
|
||||
if (wxStrcmp (buf, _T("40000000000")) != 0)
|
||||
@@ -6424,7 +6438,8 @@ int main(int argc, char **argv)
|
||||
TestLongLongConversion();
|
||||
TestBitOperations();
|
||||
TestLongLongComparison();
|
||||
TestLongLongPrint();
|
||||
TestLongLongToString();
|
||||
TestLongLongPrintf();
|
||||
}
|
||||
#endif // TEST_LONGLONG
|
||||
|
||||
|
Reference in New Issue
Block a user