Click here to Skip to main content
16,012,025 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 14:58
Tim Deveaux24-Feb-01 14:58 
GeneralRe: Casting thread functions Pin
Todd Wilson24-Feb-01 15:20
Todd Wilson24-Feb-01 15:20 
GeneralRe: Casting thread functions Pin
Tim Deveaux24-Feb-01 15:32
Tim Deveaux24-Feb-01 15:32 
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 12:55
Erik Funkenbusch26-Feb-01 12:55 
GeneralRe: Casting thread functions Pin
Todd Wilson26-Feb-01 13:13
Todd Wilson26-Feb-01 13:13 
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 13:32
Erik Funkenbusch26-Feb-01 13:32 
GeneralRe: Casting thread functions Pin
Joe Moldovan24-Feb-01 17:44
Joe Moldovan24-Feb-01 17:44 
GeneralRe: Casting thread functions Pin
Tim Deveaux25-Feb-01 5:13
Tim Deveaux25-Feb-01 5:13 
Just as a final note, it looks like this union trick has been seen before.

Stroustrup addresses this form of type conversion using unions in appendix C, section 8.3, and trounces it as non-portable, for pretty much the reasons Todd gave.

It seems that unions are poor cousins in the world of C++. Originally, I think the point was to allow C coders to save space. C++ adds some stuff that make it hard to fully assimilate unions into the language - e.g. classes with non-default ctors or dtors or copy ctors cant be used in a union (which dtor would you call?). Aside from that restriction, I get the impression that C++ has to weaken type checking in order to accomodate unions, which would explain why the union got around the parameter type checking for the calls to CreateThread and _beginthread, where no cast could. The tagged union construct (e.g. VARIANT) seems to have its place, but maybe unions should be considered harmful in C++.

Ok. I'll go away now. Smile | :) Happy coding!
GeneralRe: Casting thread functions Pin
Erik Funkenbusch26-Feb-01 13:11
Erik Funkenbusch26-Feb-01 13:11 
GeneralRe: Casting thread functions Pin
Joe Moldovan26-Feb-01 19:45
Joe Moldovan26-Feb-01 19:45 
QuestionHow to use handle_wm_notify macro which comes with win32? Pin
Sachin23-Feb-01 23:04
Sachin23-Feb-01 23:04 
AnswerRe: How to use handle_wm_notify macro which comes with win32? Pin
Sardaukar24-Feb-01 1:23
Sardaukar24-Feb-01 1:23 
GeneralOnSize Pin
Starodubtsev Sergey23-Feb-01 22:53
Starodubtsev Sergey23-Feb-01 22:53 
GeneralRe: OnSize Pin
Erik Funkenbusch26-Feb-01 13:17
Erik Funkenbusch26-Feb-01 13:17 
Generaltitle text on the main frame Pin
Starodubtsev Sergey23-Feb-01 22:20
Starodubtsev Sergey23-Feb-01 22:20 
GeneralRe: title text on the main frame Pin
Christian Graus23-Feb-01 22:23
protectorChristian Graus23-Feb-01 22:23 
Generalcreate an exe file from another Pin
Sachin23-Feb-01 15:01
Sachin23-Feb-01 15:01 
GeneralRe: create an exe file from another Pin
Tim Deveaux24-Feb-01 4:14
Tim Deveaux24-Feb-01 4:14 
QuestionHow to install source patch with VC++? Pin
23-Feb-01 13:09
suss23-Feb-01 13:09 
QuestionHow to install source patch with VC++? Pin
23-Feb-01 13:08
suss23-Feb-01 13:08 
GeneralWinsock problem - PLEASE help Pin
23-Feb-01 11:11
suss23-Feb-01 11:11 
GeneralRe: Winsock problem - PLEASE help Pin
Tim Deveaux23-Feb-01 13:06
Tim Deveaux23-Feb-01 13:06 
GeneralRe: Winsock problem - PLEASE help Pin
James R. Twine27-Feb-01 8:14
James R. Twine27-Feb-01 8:14 
QuestionSounds ?? Pin
23-Feb-01 8:39
suss23-Feb-01 8:39 
AnswerRe: Sounds ?? Pin
Christian Graus23-Feb-01 22:29
protectorChristian Graus23-Feb-01 22:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.