473,324 Members | 2,248 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Compiler warnings

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
5 3610
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
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

"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
* 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: dis | last post by:
I've been going through my code and clearing away some of the compiler warnings that i'm generating and i've come across areas where i cast pointers to integer values. The Visual Studio compiler...
20
by: News | last post by:
I'm new to c and gcc. I was wondering if anyone can point me to a web page or book that has a list of the warning messages and their meanings. Are the warnings the same no matter what compiler...
8
by: Charlie Zender | last post by:
Hi, First, this may be a GCC or Linux-specific problem, I'm not sure. I am unable to compile a large body of code with extremely pedantic compile time checks activate, so that warnings cause...
43
by: Anitha | last post by:
Hi I observed something while coding the other day: if I declare a character array as char s, and try to use it as any other character array..it works perfectly fine most of the times. It...
29
by: Daniel Rudy | last post by:
Hello, Consider the following code fragment: fileptr = fopen(param->filename, "r"); if (fileptr == NULL) { error("digest.c: digest_file: Open File ", errno); return(-2); }
2
by: Samuel | last post by:
Imagine you have the following code: try { ... } catch (ThreadAbortException eThread) { if (WorkStopped != null) WorkStopped(this, EventArgs.Empty) }
5
by: rawCoder | last post by:
Hi All, In Visual Basic .NET , your function definition might requirre you to return a value but (accidently/intentionally) you dont put any 'return value' in the function. In this case VB...
11
by: Charles Sullivan | last post by:
I have a number of functions, e.g.: int funct1( int arg1, int arg2, int arg3 ); int funct2( int arg1, int arg2, int arg3 ); int funct3( int arg1, int arg2, int arg3 ); that are called via...
3
by: gil | last post by:
Hi, I'm trying to find the best way to work with compiler warnings. I'd like to remove *all* warnings from the code, and playing around with the warning level, I've noticed that compiling with...
3
by: Peted | last post by:
Hi Im using vs2008 c# 3.0 and am going through some other person(s) code to clean up compiler warnings that are bieng produced. I have this code (at bottom) where a delegate/event is...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.