Blair Sutton

Hi all,

I am trying to port some code from VS2003 to VS2005 but I am having some problems (to be clear: the code compiles without error on VS2003). I have narrowed the problem down to this simple test case: -

cl -c -MD -DNO_STRICT test.cpp

where test.cpp only contains: -

#include <atlbase.h>
#include <atlhost.h>


When I compile this I receive the following error: -

C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE\atlwin.h(3281) : error C2440: 'return' : cannot convert from 'INT_PTR (__stdcall *)(HWND,UINT,WPARAM,LPARAM)' to 'DLGPROC'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE\atlwin.h(3280) : while compiling class template member function 'DLGPROC ATL::CDialogImplBaseT<TBase>::GetDialogProc(void)'
with
[
TBase=ATL::CWindow
]
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE\atlwin.h(3819) : see reference to class template in
stantiation 'ATL::CDialogImplBaseT<TBase>' being compiled
with
[
TBase=ATL::CWindow
]
C:\Program Files\Microsoft Visual Studio 8\VC\ATLMFC\INCLUDE\atlwin.h(3851) : see reference to class template instantiation 'ATL::CSimpleDialog<t_wDlgTemplateID,t_bCenter>' being compiled


If I disable STRICT type checking by using: -

cl -c -MD test.cpp

the code compiles without any errors.

Am I missing something fundamental here

Thanks in advance
Blair



Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Simple Samples

I think so.

STRICT causes the headers to be more strict about data types, which reduces the chance for making mistakes. Since the interface between Windows functions and Windows applications allows data to be used that are not valid types, it is easy to make mistakes. The STRICT symbol helps by ensuring that data types are correct, as much as possible. Using STRICT might seem more difficult, but it can save a lot of time by ensuring you don't mistakes that can be a lot of work to find.






Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Blair Sutton

Thanks for your reply. I do understand the purpose of using STRICT. The confusion is why trying to compile code with just 2 simple #include directives causes the compiler to complain. I guess my direction of questioning is leaning more towards: is this a VS2005 bug




Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Simple Samples

Why do you say there is a bug What is the compiler doing that it should not do or what is it not doing that it should do

With NO_STRICT defined, it complains that:

INT_PTR (__stdcall *)(HWND,UINT,WPARAM,LPARAM)

cannot be converted to:

DLGPROC

Right How is DLGPROC defined The compiler is helping you to look at the relevant code, so it is easier for you to look at it than for I to look at it. Is it a valid for the compiler to complain






Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Blair Sutton

Firstly, I am not saying there is a bug, I am asking! Secondly, the header atlhost.h is provided by Microsoft (with VS2005), so surely it is they who should check this stuff compiles with NO_STRICT defined before releasing the software, don't you think




Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Simple Samples

I don't see a problem. Is there something saying that ATL works with NO_STRICT defined




Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Blair Sutton

If you read my original question you may have implied it used to work with VS2003. Sam, I know you mean well but I think you are out of your league here. Maybe someone with a little more ATL experience might know the answer. I probably will also file a bug report with Microsoft regarding the matter.




Re: Visual C++ General atlhost.h and NO_STRICT gives C2440

Simple Samples

Blair Sutton wrote:
If you read my original question you may have implied it used to work with VS2003.
You think you made that clear but it is not clear. I am sorry if that is frustrating, but I have posted questions in the past in which I think I am clear yet people say I am not. I am someone that has seen thousands of questions so I at least know how important it is to be clear when I write a question yet people say they don't understand. Yes, you implied that it works using VS 2003 but it was not clear.