By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,433 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,433 IT Pros & Developers. It's quick & easy.

Compiler warnings

P: n/a
I'm getting some strange warnings when I compile:

pointer truncation from 'HMENU' to 'unsigned int'

The line in question is:
AppendMenu(hMenu,MF_STRING|MF_POPUP,UINT(hStyle)," Style");
(where hStyle is HMENU type)
This line is exactly the same as a line in another app I have but that one
doesn't give a warning.

Other warnings are:
pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to
'LONG'
conversion from 'LONG' to 'WNDPROC' of greater size
pointer truncation from 'WNDPROC' to 'LONG'

The lines in question are:
WNDPROC
_Wallpaper=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC ,(LONG)WallpaperProc);
SetWindowLong(GetDlgItem(hwndDlg,IDC_WALLPAPER),GW L_WNDPROC,(LONG)_Wallpaper);

Why should this be? My code works and the app functions as expected. I'm
sure I shouldn't get those warnings though.
Nov 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Lindsay wrote:
I'm getting some strange warnings when I compile:

pointer truncation from 'HMENU' to 'unsigned int'

The line in question is:
AppendMenu(hMenu,MF_STRING|MF_POPUP,UINT(hStyle)," Style");
(where hStyle is HMENU type)
This line is exactly the same as a line in another app I have but that one
doesn't give a warning.

Other warnings are:
pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to
'LONG'
conversion from 'LONG' to 'WNDPROC' of greater size
pointer truncation from 'WNDPROC' to 'LONG'

The lines in question are:
WNDPROC
_Wallpaper=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC ,(LONG)WallpaperProc);
SetWindowLong(GetDlgItem(hwndDlg,IDC_WALLPAPER),GW L_WNDPROC,(LONG)_Wallpaper);

Why should this be? My code works and the app functions as expected. I'm
sure I shouldn't get those warnings though.


None of your code is standard C++ so is off topic here. Try asking on
news:comp.os.ms-windows.programmer.win32.

Looks to me though that your warning are to do with VC++ gently
reminding you that pointers cannot safely be converted to integers or
vice versa. With 64-bit computing round the corner, the VC++ compiler
has got a lot more fussy about this issue.

john
Nov 22 '05 #2

P: n/a
Lindsay wrote:
I'm getting some strange warnings when I compile:

pointer truncation from 'HMENU' to 'unsigned int'
Apparently pointers on your system are bigger than 'unsigned int'. I can
only speculate that you must be on Win64.
The line in question is:
AppendMenu(hMenu,MF_STRING|MF_POPUP,UINT(hStyle)," Style");
(where hStyle is HMENU type)
This line is exactly the same as a line in another app I have but that one
doesn't give a warning.
Are you sure you're building both apps for the same target platform?
Other warnings are:
pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to
'LONG'
conversion from 'LONG' to 'WNDPROC' of greater size
pointer truncation from 'WNDPROC' to 'LONG'
Again, sizeof(yourpointertypeabove) > sizeof(LONG).
The lines in question are:
WNDPROC
_Wallpaper=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC ,(LONG)WallpaperProc);
SetWindowLong(GetDlgItem(hwndDlg,IDC_WALLPAPER),GW L_WNDPROC,(LONG)_Wallpaper);

Why should this be? My code works and the app functions as expected. I'm
sure I shouldn't get those warnings though.


If you're sure, you need to complain to the maker of your compiler.

V
Nov 22 '05 #3

P: n/a

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:vS******************@newsread1.mlpsca01.us.to .verio.net...
Lindsay wrote:
I'm getting some strange warnings when I compile:

pointer truncation from 'HMENU' to 'unsigned int'
Apparently pointers on your system are bigger than 'unsigned int'. I can
only speculate that you must be on Win64.


No. Both apps are Win32.
The line in question is:
AppendMenu(hMenu,MF_STRING|MF_POPUP,UINT(hStyle)," Style");
(where hStyle is HMENU type)
This line is exactly the same as a line in another app I have but that
one doesn't give a warning.


Are you sure you're building both apps for the same target platform?


Yes. They are both the same.
Other warnings are:
pointer truncation from 'LRESULT (__stdcall *)(HWND,UINT,WPARAM,LPARAM)'
to 'LONG'
conversion from 'LONG' to 'WNDPROC' of greater size
pointer truncation from 'WNDPROC' to 'LONG'


Again, sizeof(yourpointertypeabove) > sizeof(LONG).
The lines in question are:
WNDPROC
_Wallpaper=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC ,(LONG)WallpaperProc);
SetWindowLong(GetDlgItem(hwndDlg,IDC_WALLPAPER),GW L_WNDPROC,(LONG)_Wallpaper);

Why should this be? My code works and the app functions as expected. I'm
sure I shouldn't get those warnings though.


If you're sure, you need to complain to the maker of your compiler.


How I would love to complain to MS. But it doesn't explain why one app is ok
and this one gives warnings. V

Nov 22 '05 #4

P: n/a
* Lindsay:

I'm getting some strange warnings when I compile:
pointer truncation from 'HMENU' to 'unsigned int'


Assuming Microsoft Visual C++:

That's probably because you are compiling with 64-bit compatibility
checking enabled. Then the compiler complains about things that won't
work somewhere in the future, plus a few things that will work in the
future but that it doesn't understand will work. That includes that it
may complain about e.g. giving a std::size_t to std::cout.

If you upgrade to version 8.x, assuming you haven't, then you may get
additional warnings on things like std::string::copy, because that
compiler team is really into warnings -- cry wolf, is their motto.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 22 '05 #5

P: n/a
Lindsay wrote:
[..]
How I would love to complain to MS. But it doesn't explain why one
app is ok and this one gives warnings.


Post to microsoft.public.vc.language -- that's where they talk VC++.

V
Nov 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.