Advertisement

void \ LPVOID....?

Started by February 08, 2002 11:46 PM
6 comments, last by Mardigin 22 years, 7 months ago
I have seen a lot of functions written by other programmers that take void* this or LPVOID that. I thought I understood what void was, and now I am not so sure. I know that if you do not want to return anything then you place void in front of the function. Why have a void perameter? what is LPVOID all about?
I haven''t programmed Windows yet, but I''m guessing its Window''s API programming specific....
LP stands for........
....
Can''t remember...so sleepy....
Something about the variables and the stack..I think....
Anyways, why use BOOL when theres bool in Windows programming? There might be a difference, or it might just be so Windows programs look cool (I haven''t really looked into this, but I have a feeling some smart-ass is going to reply and correct me)

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin
"I've learned something today: It doesn't matter if you're white, or if you're black...the only color that really matters is green"-Peter Griffin
Advertisement
hi! well, could you also send me your ''pong'' game? i''d really like to see, if you don''t mind, i''d also like to see the source code. thanks!

davidang@info.com.ph
http://www.dualforcesolutions.comProfessional website designs and development, customized business systems, etc.,
LP stands for "long pointer." LPVOID is basically just a typedef for void*. Microsoft really likes to make archaic typedefs for simple things. I have no idea why.
quote: Original post by Mardigin
Why have a void perameter? what is LPVOID all about?

Ah, but LPVOID is not a void parameter. It''s a void pointer - a pointer to an unspecified type and generally means you cast your parameter (which should be a pointer) to pass it to such a function. For example the CreateThread Win32 API function takes an LPVOID parameter as the address of the thread procedure. If I have a function DoSomethingThreaded, then to pass it to CreateThread I
CreateThread(..., (void *)&DoSomethingThreaded, ...); 

Note the ampersand (&) in front of the function name; that returns the address of the function - a pointer to the function. What''s the type of that pointer? Whatever the function type is. How can I build a function that works for all function types? Use a void pointer.

I wanna work for Microsoft!
[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!
Why the ampersand?
I thought writing a function without the () would already be the function's adress...

nik

Edited by - LeMatsch on February 9, 2002 4:37:35 AM
Advertisement
Thanks a bunch for all who replied.

Can you also use void * for data structures or data types? Could I use void or void * and pass it an int\long\double\...? Could I use it to write a generic move function that changes the x y co-ordinates of any given structure in my game?

Thank you.
LONG POINTER! Thats it!!

You can use void*, but its much safer not to (it defeates the whole purpose of type checking)

"I''ve learned something today: It doesn''t matter if you''re white, or if you''re black...the only color that REALLY matters is green"
-Peter Griffin
"I've learned something today: It doesn't matter if you're white, or if you're black...the only color that really matters is green"-Peter Griffin

This topic is closed to new replies.

Advertisement