|
Environment:
Windows XP Professional 32-bit
Visual Studio C++ Express Edition 8.0 SP2
Platform SDK Windows 2003 Server RC2
Project: C++, Windows 32-bit (x86), Debug, Unicode
<br />
Compiling...<br />
Dialog.cpp<br />
d:\lbm\bdm\dialog.cpp(43) : warning C4244: 'argument' : conversion from 'LONG' to 'LONG', possible loss of data<br />
[rest of compilation continues]<br />
The code triggering the warning message:
#ifdef _WIN64
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
#else
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG __w64)(wcDlgInfo->m_wcDlgProc));
#endif
Normally the line
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
would suffice, but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit:
Compiling...
Dialog.cpp
d:\lbm\bdm\dialog.cpp(47) : warning C4244: 'argument' : conversion from 'LONG_PTR' to 'LONG', possible loss of data
Any ideas why
- LONG_PTR is considered "larger" than LONG on 32-bit x86, and
- what means exactly the "conversion from LONG to LONG" warning message means, since _WIN64 is not defined?
Many thanks,
Cristian Amarie
|
|
|
|
|
I'm not sure about the error message, but...
Cristian Amarie wrote: but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit
A LONG_PTR IS a 64-bit value in a 64-bit build. That's the whole reason for the newer type. It's
a LONG but large enough to hold a pointer when pointers are 32-bit or 64-bit.
I'm not sure what a "LONG __w64" is, but this line...
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG __w64)(wcDlgInfo->m_wcDlgProc));
...won't work on a 32-bit build because pointers are 32-bit therefore you need to pass a 32-bit
value. Sure, you can cast a 64-bit but it's going to be truncated to 32-bits.
Mark
|
|
|
|
|
[A LONG_PTR IS a 64-bit value in a 64-bit build]
True, but as I stated in environment, is a 32-bit build.
[I'm not sure what a "LONG __w64" is, but this line...]
(Microsoft Specific) Lets you mark variables, such that when you compile with /Wp64 the compiler will report any warnings that would be reported if you were compiling with a 64-bit compiler.
Is a "marker".
About the last part of message, true, but (LONG __w64) was on #else part of #ifdef _WIN64.
|
|
|
|
|
Hmm
What type is wcDlgInfo->m_wcDlgProc?
|
|
|
|
|
typedef LRESULT (CALLBACK *WCDLGPROC)(HWND, UINT, WPARAM, LPARAM);
m_wcDlgProc is a pointer (to a window procedure).
|
|
|
|
|
Yeah that's a good WTF
This...
::SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG)(LONG_PTR)(wcDlgInfo->m_wcDlgProc));
..."fixes" it on VS2003.
I'd call that a bug, but every time I do, someone has a good reason for the behavior
|
|
|
|
|
Now that's a stretch (Dad to DeeDee - Dexter's Laboratory)
|
|
|
|
|
Cristian Amarie wrote: Normally the line
SetWindowLongPtr(hdlg, DLGWINDOWEXTRA, (LONG_PTR)(wcDlgInfo->m_wcDlgProc));
would suffice, but this also complains about the conversion of LONG_PTR to LONG, as if LONG_PTR is 64-bit:
I aggree with you. This should suffice. About warning, probably this could be issue with IDE.
|
|
|
|
|
Hello,
I have 2 times which I would like to subtract.
One time is a time that consists of hours, minutes, seconds and milliseconds. For instance 12:24:59.0.
and the other time is a timer which consists only of milliseconds, seconds and minutes (no hours). For instance: 4.52.300.
The problem is that I need to subtract the two times and get a result which also contains the difference in milliseconds (this is critical for the timer).
I tried converting both times to COleDateTime, then subtracting them but I don't get the result in Milliseconds, so I lose information.
By the way, I have both times in SYSTEMTIME format but is there a function that subtracts them?
Any other ideas?
|
|
|
|
|
SWDevil wrote: By the way, I have both times in SYSTEMTIME format but is there a function that subtracts them?
Convert SYSTEMTIME to FILETIME using SystemTimeToFileTime . Convert FILETIME to ULARGE_INTEGER and use it for artimetic operations.
|
|
|
|
|
I would like to use a vector to hold a large volume of data. So, I conducted a test with std::vector. However, the value of 'Sum' is 16677720, instead of 100, 000, 000. However, i can get the value 100, 000, 000 when declare 'Sum' as unsigned int type. Why? My pc has 32-bit bus address.
<br />
vector <float> DDD;<br />
<br />
DDD.reserve.((10000 * 10000)/2*6)<br />
<br />
float x= (float)1;<br />
for(int i = 0; i < (10000 * 10000); i++)<br />
{<br />
DDD.push_back(x);<br />
}<br />
float Sum = 0;<br />
for(int j = 0; j < (10000 * 10000); j++)<br />
{<br />
Sum += DDD[j];<br />
}<br />
|
|
|
|
|
The problem is with using a float, not 32 bit integers.
Your floats only have a precision of 7 digits. If you must use a floating point value then at
least use a double
|
|
|
|
|
Which function similar to GetTickCount() to get time in us (1/1000 ms) level?
|
|
|
|
|
You want microsecond (1/1000 msec) resolution? If so, that's not possible.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
GetSystemTime contains all up to milliseconds.
|
|
|
|
|
|
great!
QueryPerformanceCounter() works perfect!
It is really impossible if you are not good enough.
|
|
|
|
|
Hello!
I use Visual Studio 2005 SP 1. Here it a part of my code:
CStdioFile fd;
CString t;
fd.Open(_T("rep.txt"), CFile::modeRead, 0);
fd.ReadString(t);
This file contains the russian language and when I use debugger I see that 't' contains is 'm_pszData 0x003BBA60 "CSAD|Air Tube (òðóáêà äëÿ îòâîäà òåïëà îò ïðîöåññîðà)|2" wchar_t*'
You see, that russian part is unreadable. My project has Unicode libraries support and I can use Russian in my project, but 'Read string' has the problem. Can you help me?
|
|
|
|
|
yaros21 wrote: ...when I use debugger I see that 't' contains is 'm_pszData 0x003BBA60...
Are you viewing it with the "su" debugger symbol?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks you, but I've already solve it. In project properties I switched 'Character set' to 'Use multi-Byte character set' and it works well now. Unicode isn't crucial for my project.
|
|
|
|
|
i am using the .NET.
i need to fetch the attributes from the wmv/wma file.
e.g. time(created,access,modified)bitrate,size,duration,extension(avi/mpeg/wmv).
i have used the above API function FileTimeToSystemTime(&ft,st)
ft is FILETIME.
where st is LPSYSTEMTIME.
When i debug it gives memory error.
all these attributes i need to display in the listview like search which gives us
all files list information with attributes.
Thanks in advance
amit mistry
|
|
|
|
|
LPSYSTEMTIME st
is the same as
SYSTEMTIME*st;
you must do in this way:
SYSTEMTIME st;
FileTimeToSystemTime(&ft,&st)
|
|
|
|
|
Hi,
I tried to raise an event from unmanaged code class to a class in managed code.
I passed a delegate pointer (using Marshal) to the unmanaged class but I got an error when the unmanaged class tried to execute the function.
I tried to use pin_ptr to the delegate pointer with no results.
How can I raise event from unmanaged code class to a managed code class using delegate (managed) and function pointer(unmanaged)?
Thanks
|
|
|
|
|
I don't think that it is possible to raise event directly from unmanaged code, but it is possible to call managed callback function which does this. Use Marshal.GetFunctionPointerForDelegate method to pass managed callbak function address to unmanaged code.
Keep delegate instance alive all time when callback function can be called.
|
|
|
|
|
Thanks for your reply,
I've a delegate instance that lives all the time and I sent it to the unmanaged code using Marshal.GetFunctionPointerForDelegate.
But I think there is a problem with the GC since it can be reallocated the delegate on the heap.
How can it be handle?
Thanks
|
|
|
|