Re: Visual C++6, MFC project to Visual Studio 2005 MFC

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Tue, 22 Jan 2008 11:40:38 -0800 (PST), "Andrea Müller" <post2727@xxxxxxxx> wrote:

Hello,

I convert a Visual C++6, MFC project to Visual Studio 2005 MFC and
I have a lot of warnings.

What I want?
I want to sitch off the warnings and I make following without good
result.
How is the correct way to do this?

File: stdafx.h

#if !
defined(AFX_STDAFX_H__63C457B5_7B4F_11D5_A777_0001021D6D89__INCLUDED_)
#define AFX_STDAFX_H__63C457B5_7B4F_11D5_A777_0001021D6D89__INCLUDED_


#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


#define _CRT_SECURE_NO_DEPRECATE 1


#ifdef _MSC_VER_VS2005
# pragma warning(disable:4927)
****
More than one user-defined conversion has been implicitly applied

Sounds like something worth finding out about!
****
# pragma warning(disable:4244)
****
This says you are losing data. This seems very important to know about. Note that there
are serious inconsistencies in the world, such as APIs that take DWORDs which are received
from functions that now return INT_PTR or UINT_PTR or DWORD_PTR, but note that if you are
getting these when you cast handles or pointers to int, DWORD, long, UINT, or INT, your
code should be considered erroneous and should be fixed. That is, code like this is now
incorrect:
Something * ptr;
,,,assign something to ptr
DWORD x = (DWORD)ptr;
Therefore, you need to be cautious and put in your own casts to say it is OK, but only if
you depend on it being OK
****
# pragma warning(disable:4018)
****
Signed/unsigned mismatch. This IS an error, and apparently snuck through your VS6 builds,
but it represents a genuine error in your program. Fix it.
****
# pragma warning(disable:4311)
****
This indicates 64-bit to 32-bit truncation, and means your program will not compile for
Win64. As pointed out, perhaps you should disable the /Wp64 option in your build, but
ultimately you will have to fix all such errors if you expect to port to Win64
****
# pragma warning(disable:4312)
****
This warning indicates youa are going to lose signedness, e.g.,
int x = -1;
LPVOID p = (LPVOID)x;
means that
ASSERT((ULONGLONG)p == (ULONGLONG)-1);
is not true. This COULD get you in trouble in a 64-bit port, so such errors need to be
examined carefully
****
#endif


Second question:
m_ListCtrl.SetItemData( nZeile, (DWORD) pArtikelposition );
warning C4311: 'Type': Pointer 'CArtikelposition
*' to 'DWORD'
****
As already pointed out, you should use (DWORD_PTR) here. (DWORD) is not portable to
64-bit environment, and in fact, you SHOULD have used
m_ListCtrl.SetItemDataPtr(nZeile, pArtikelposition);
intead of SetItemData.
joe
****

How can I do it correct?


Regards Andrea

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Visual C++6, MFC project to Visual Studio 2005 MFC
    ... MFC project to Visual Studio 2005 MFC and ... I have a lot of warnings. ... # pragma warning ... m_ListCtrl.SetItemData(nZeile, (DWORD) pArtikelposition); ...
    (microsoft.public.vc.mfc)
  • Re: Tcl 8.5 HP/UX Compiler warnings
    ... results and "the optional HP ANSI C compiler", ... stat64 struct pointers are being ... The elementary types of the structure ... other warnings I cited are similarly harmless. ...
    (comp.lang.tcl)
  • Re: How to name variables in a program?
    ... >> Ever since I picked up the book Windows programming book by Petzold, ... > libraries that use the unpronouncable name LPCTSTR, ... > various 48-bit segmented pointers, ... of the less ambiguous DWORD. ...
    (comp.programming)
  • Re: Warnings calling functions in other object files by pointer
    ... >> I am making calls from one compilation unit to functions in another by ... >> pointers and I get the warnings below from gcc on 2.4.x Debian ... spelling errors, but to me many spelling errors are non-obvious. ...
    (comp.lang.c)
  • Re: Tcl 8.5 HP/UX Compiler warnings
    ... I have checked the core sources and tcl either uses 'struct ... That the compiler is complaining about feeding the ... that's because file descriptors really are pointers on some ... > other warnings I cited are similarly harmless. ...
    (comp.lang.tcl)