c:\wxWidgets-2.6.3\include\wx\longlong.h(169) : warning C424 Topic is solved

Do you have a question about makefiles, a compiler or IDE you are using and need to know how to set it up for wxWidgets or why it doesn't compile but other IDE's do ? Post your questions here.
Post Reply
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

c:\wxWidgets-2.6.3\include\wx\longlong.h(169) : warning C424

Post by davebee »

I have a perefectly building & running wxWidgets based application. However, for almost every module I compile, I get the following warning message (which quite frankly has become annoying):
c:\wxWidgets-2.6.3\include\wx/longlong.h(169) : warning C4244: 'return' : conversion from 'const __int64' to 'double', possible loss of data
Is there a way to get rid of it without lowering warning level?

Thanks,
Dave

P.S. wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

looks like you have enabled 64bit support,
do you need that ?
-tiwag
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

Post by davebee »

tiwag wrote:looks like you have enabled 64bit support
Huh??? :-s

I am using a 32-bit platform, so I have no idea what you mean by "enabled 64bit support". The only place in setup.h where "64" is mentioned is in reference to wxUSE_LONGLONG. Is that what you meant?
tiwag wrote:ldo you need that ?
I certainly don't need that, but the wxUSE_LONGLONG documentation says:
// Set wxUSE_LONGLONG to 1 to compile the wxLongLong class. This is a 64 bit
// integer which is implemented in terms of native 64 bit integers if any or
// uses emulation otherwise.
//
// This class is required by wxDateTime and so you should enable it if you want
// to use wxDateTime. For most modern platforms, it will use the native 64 bit
// integers in which case (almost) all of its functions are inline and it
// almost does not take any space, so there should be no reason to switch it
// off.
//
// Recommended setting: 1
And I do intend to use wxDateTime, so I just left it at the default (recommended) setting.

Thanks,
Dave
wxMSW-2.6.3 / Visual C++ 2005 EE / Windows XP SP2

(was: wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5)
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

davebee wrote:
tiwag wrote:looks like you have enabled 64bit support
Huh??? :-s

I am using a 32-bit platform, so I have no idea what you mean by "enabled 64bit support"...
i meant the other way round, in your compiler settings :)

newer compilers have special support for 64bit , if you enable these features,
maybe any macro get's defined, which then uses long long 's where in a 32bit build it would use long's .

edit: i just now have read from your sig, that you use VC6
this could be the problem, post a small sample which shows your
problem, and we can help you, at least we can find out if it is a compiler problem or if you've screwed your wx-build
-tiwag
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

Post by davebee »

i meant the other way round, in your compiler settings
I am afraid that I don't understand: How do I enable 64-bit support in my compiler settings (I am using Visual C++ 6.0)?

Also, the warning I am getting is not for a particular snippet of code that I am using, but rather for all and any modules (that include the wx headers) that I compile. It always points to line 169 in longlong.h which reads:
#if wxABI_VERSION >= 20602
// convert to double
double ToDouble() const { return m_ll; }
#endif // ABI >= 2.6.2
Any idea what's happening?

Thanks,
Dave
wxMSW-2.6.3 / Visual C++ 2005 EE / Windows XP SP2

(was: wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5)
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

Code: Select all

#include <wx/wx.h>


int main(int argc, char **argv)
{
    wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
    wxInitializer initializer;
    if ( !initializer )
    {
        fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
        return -1;
    }

    /* my code */
    wxString wxABIv = wxT("wxABI_VERSION = ");
    wxABIv << wxABI_VERSION;
    wxPuts(wxABIv);

    wxString wxVER = wxT("wxVERSION_STRING = ");
    wxVER << wxVERSION_STRING;
    wxPuts(wxVER);


    return 0;
}

you can test it with the above program,

you are right, VC6 does likely don't support 64bit compilation, but i'm not shure :wink:
-tiwag
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

also, you could just disable this specific warning

Code: Select all

#pragma warning (disable : 4244)
or change the line in longlong.h

Code: Select all

double ToDouble() const { return (double)m_ll; } 
to get rid of the warning
Use the source, Luke!
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

doublemax wrote:also, you could just disable this specific warning

Code: Select all

#pragma warning (disable : 4244)
or change the line in longlong.h

Code: Select all

double ToDouble() const { return (double)m_ll; } 
to get rid of the warning
but it find it interesting, why he DOES get the warning, that's not normal i guess.
-tiwag
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

Post by davebee »

tiwag wrote:but I find it interesting, why he DOES get the warning, that's not normal i guess.
tiwag, I finally got around to trying your code snippet (as you posted above). Here are the results:
--------------------Configuration: console - Win32 DLL Unicode Debug--------------------
Compiling...
console.cpp
c:\wxWidgets-2.6.3\include\wx/longlong.h(169) : warning C4244: 'return' : conversion from 'const __int64' to 'double', possible loss of data
D:\tmp\console\console.cpp(4) : warning C4100: 'argv' : unreferenced formal parameter
D:\tmp\console\console.cpp(4) : warning C4100: 'argc' : unreferenced formal parameter
Linking...

console.exe - 0 error(s), 3 warning(s)
I hope you can shed some light on the mystery, since I myself have no clue why this warning.

Before trying to modify wxWidgets sources I would like to understand where it comes from, since in a previous W2K/VC6 wxWidgets-based development environment I don't remember having this warning.

Thanks,
Dave
wxMSW-2.6.3 / Visual C++ 2005 EE / Windows XP SP2

(was: wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5)
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

dave, can you run the program and post the output here

something like

Code: Select all

wxABI_VERSION = 20699
wxVERSION_STRING = wxWidgets 2.6.3

also i don't know where VC6 stores all the commandline flags ands options,
this would be needed also in order to find the reason.

VS2003 produces some html file, where the exact commandline for compiler and linker is shown.

try to find this information for your project
-tiwag
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

a) the warning itself is justified, conversion from 64bit integer to double can lose data

b) the wxABI_VERSION macro and wxLongLong::ToDouble() were both introduced in wx 2.6.2, that's probably the reason why you didn't see the warning before

c) in wx 2.7.x the code line looks different already and without the wxABI_VERSION check:

Code: Select all

double ToDouble() const { return wx_truncate_cast(double, m_ll); }
Use the source, Luke!
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

@doublemax - do you think the above is only an issue of some 64bit code warning flag, which can (maybe) turned off in VC6 ?
-tiwag
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

Post by davebee »

tiwag wrote:dave, can you run the program and post the output here?
Gladly. Here is my output:
~/tmp/console/vc_mswuddll> ./console
wxABI_VERSION = 20699
wxVERSION_STRING = wxWidgets 2.6.3
tiwag wrote:also i don't know where VC6 stores all the commandline flags ands options, this would be needed also in order to find the reason.

VS2003 produces some html file, where the exact commandline for compiler and linker is shown.

try to find this information for your project
In VC6 it is also in an HTML file named <projectname>.plg. Here is the relevant part you were looking for:
Command Lines
Creating temporary file "C:\DOCUME~1\dave\LOCALS~1\Temp\RSP89.tmp" with contents
[
/nologo /MDd /W4 /Gm /GR /Zi /Od /I "c:\wxWidgets-2.6.3\lib\vc_dll\mswud" /I "c:\wxWidgets-2.6.3\include" /I "." /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_CONSOLE" /D wxUSE_GUI=0 /Fo"vc_mswuddll\console/" /Fd"vc_mswuddll\console.pdb" /FD /GZ /EHsc /c
"D:\dave\tmp\console\console.cpp"
]
Creating command line "cl.exe @C:\DOCUME~1\dave\LOCALS~1\Temp\RSP89.tmp"
Creating temporary file "C:\DOCUME~1\dave\LOCALS~1\Temp\RSP8A.tmp" with contents
[
wxbase26ud_net.lib wxbase26ud_odbc.lib wxbase26ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:console /incremental:yes /pdb:"vc_mswuddll/console.pdb" /debug /machine:I386 /out:"vc_mswuddll/console.exe" /libpath:"c:\wxWidgets-2.6.3\lib\vc_dll"
.\vc_mswuddll\console\console.obj
]
Creating command line "link.exe @C:\DOCUME~1\dave\LOCALS~1\Temp\RSP8A.tmp"
I hope this will shed some light on the mystery. I haven't read doublemax's reply thoroughly yet, but I have a feeling that he provides a satisfactory explanation. I will need to examine it and see if I understand what it means.
wxMSW-2.6.3 / Visual C++ 2005 EE / Windows XP SP2

(was: wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5)
davebee
Earned some good credits
Earned some good credits
Posts: 106
Joined: Fri Oct 06, 2006 1:39 am

Post by davebee »

doublemax wrote:a) the warning itself is justified, conversion from 64bit integer to double can lose data

b) the wxABI_VERSION macro and wxLongLong::ToDouble() were both introduced in wx 2.6.2, that's probably the reason why you didn't see the warning before

c) in wx 2.7.x the code line looks different already and without the wxABI_VERSION check.
doublemax, thank you very much! I just did what you suggested (with a slight modification): I replaced line 169 in longlong.h:

Code: Select all

    double ToDouble() const { return m_ll; }
With:

Code: Select all

    double ToDouble() const { return wx_truncate_cast(double, m_ll); }
Everything now compiles so cleanly! :D

I consider this issue a "slight bug" in wx 2.6.3.

Dave
wxMSW-2.6.3 / Visual C++ 2005 EE / Windows XP SP2

(was: wxMSW-2.6.3 / Visual C++ 6.0 SP6 / Windows 2000 SP5)
tiwag
Earned some good credits
Earned some good credits
Posts: 123
Joined: Tue Dec 21, 2004 8:51 pm
Location: Austria

Post by tiwag »

hi dave

it's good, that you found your solution,
davebee wrote: I consider this issue a "slight bug" in wx 2.6.3.
your compiler is right with this warning, it depends on the warning-level.

check your documentation of VC6 about all the switches and i'm shure,
that there is one, which controls the behaviour.

since i'm working with gcc, i'm not familiar with the M$ compilers and
don't know all the switches. but i'm curious why gcc doesn't emit such a warning ...

brgds, tiwag
-tiwag
Post Reply