15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


'OnActivateApp' : cannot convert parameter 2 from 'void *'

Hans Wedemeyer -- hansw@sprintmail.com
Wednesday, March 05, 1997

Environment: VC++4.2b, Windows NT 4.0 

I get the error message when trying to use VC++ generated code 

MainFrm.cpp(462):error C2664: 'OnActivateApp' : cannot convert parameter
2 from 'void *' to 'struct HTASK__ *' (new behavior; please see help) 

The code delivered by Class Wizard looks like this


void CMainFrame::OnActivateApp(BOOL bActive, HTASK hTask) 
{
	CMDIFrameWnd::OnActivateApp(bActive, hTask);      // Obs! note for
clarity, added by Hans W, this is line 462 referred to
	
	// TODO: Add your message handler code here
	
}


I made a new project and added the same message handler using Class
Wizard and it compiles with No errors !

I don't like the inconsistency.

As I added NO extra code I expected it to compile error free! 

Some it does, sometime it does not !

why?

regards
Hans Wedemeyer
hansw@sprintmail.com



Mike Blaszczak -- mikeblas@nwlink.com
Thursday, March 06, 1997

At 09:47 3/5/97 -0600, you wrote:
>Environment: VC++4.2b, Windows NT 4.0 
>
>I get the error message when trying to use VC++ generated code 
>
>MainFrm.cpp(462):error C2664: 'OnActivateApp' : cannot convert parameter
>2 from 'void *' to 'struct HTASK__ *' (new behavior; please see help) 

[...]

>As I added NO extra code I expected it to compile error free! 

Uh, I don't get it: you're saying that you added no code and expected
it to compile error free, but then you say:

>I made a new project and added the same message handler using Class
>Wizard and it compiles with No errors !

which means that you added no code and it _did_ compile error free.

>Some it does, sometime it does not !

Depending on what?  Did you really add code, or not?  What code did
you add?

In the meantime, it turns out that HTASK, like all other Windows handle
types, are defined differently depending on the preprocessor symbol
STRICT being defined when you include windows.h.

If STRICT is defined, HTASK ends up really being a pointer to an
empty structure named HTASK__, and if STRICT isn't defined, HTASK ends
up really being a pointer to void.  It seems like you've either somehow
not defined STRICT, or that you've included an alternate definition
of HTASK from some other goofy header someplace.

If you include afxwin.h as you're supposed to, you should get WINDOWS.H
with STRICT properly predefined.


.B ekiM
  Crotch Rocket   / Full-Body Rocket / http://www.nwlink.com/~mikeblas/
95 Honda VFR-750F /   94 Mazda RX-7  / Trip Report Central!
                 Less work, more hockey!
  These words are my own - I do not speak on behalf of Microsoft.



Hans Wedemeyer -- hansw@sprintmail.com
Sunday, March 09, 1997

Environment: VC++4.2b, Windows NT 4.0

Thanks, well I looked for "goofy" headers and I found one, actually
included by a commerical library that I "was" using. 
regards
Hans W
P.S. Why is it that MS does not include descriptions like the one you
gave here ?
Error message desriptions ARE better today, I remember the  C compiler
version 4.0 where error message descriptions could be as brief  as 
"An error occurred" (not very helpful)
 
Thanks again.



Mike Blaszczak wrote:
> 
> At 09:47 3/5/97 -0600, you wrote:
> >Environment: VC++4.2b, Windows NT 4.0
> >
> >I get the error message when trying to use VC++ generated code
> >
> >MainFrm.cpp(462):error C2664: 'OnActivateApp' : cannot convert parameter
> >2 from 'void *' to 'struct HTASK__ *' (new behavior; please see help)
> 
> [...]
> 
> >As I added NO extra code I expected it to compile error free!
> 
> Uh, I don't get it: you're saying that you added no code and expected
> it to compile error free, but then you say:
> 
> >I made a new project and added the same message handler using Class
> >Wizard and it compiles with No errors !
> 
> which means that you added no code and it _did_ compile error free.
> 
> >Some it does, sometime it does not !
> 
> Depending on what?  Did you really add code, or not?  What code did
> you add?
> 
> In the meantime, it turns out that HTASK, like all other Windows handle
> types, are defined differently depending on the preprocessor symbol
> STRICT being defined when you include windows.h.
> 
> If STRICT is defined, HTASK ends up really being a pointer to an
> empty structure named HTASK__, and if STRICT isn't defined, HTASK ends
> up really being a pointer to void.  It seems like you've either somehow
> not defined STRICT, or that you've included an alternate definition
> of HTASK from some other goofy header someplace.
> 
> If you include afxwin.h as you're supposed to, you should get WINDOWS.H
> with STRICT properly predefined.
> 
> .B ekiM
>   Crotch Rocket   / Full-Body Rocket / http://www.nwlink.com/~mikeblas/
> 95 Honda VFR-750F /   94 Mazda RX-7  / Trip Report Central!
>                  Less work, more hockey!
>   These words are my own - I do not speak on behalf of Microsoft.



Mike Blaszczak -- mikeblas@nwlink.com
Tuesday, March 11, 1997

At 13:05 3/9/97 -0600, Hans Wedemeyer wrote:
>Environment: VC++4.2b, Windows NT 4.0

>Thanks, 

Wow!  I've been thanked!  I'm not even sure what to say!

>P.S. Why is it that MS does not include descriptions like the one you
>gave here ?

The compiler simply doesn't have enough information to give a more 
detailed description.  The compiler is reporting the problem it detected
and giving almost all of the information that it has available to you.

The compiler doesn't know how STRICT was designed, and doesn't understand
anything about the difference between "struct HTASK__ *" and "HTASK".
Within the bounds of the language, there's no way to express any more
information than the data type itself.


.B ekiM
http://www.nwlink.com/~mikeblas/
These words are my own. I do not speak on behalf of Microsoft.
           This performance was not lip-synched.





Become an MFC-L member | Вернуться в корень Архива |