functionname(void) or functionname(*void)

Just starting out? Need help? Post your questions and find answers here.
funnyguy
User
User
Posts: 69
Joined: Mon Jun 23, 2008 10:57 pm

functionname(void) or functionname(*void)

Post by funnyguy »

When writing a function for a thread which one is correct? functionname(void) or functionname(*void)?
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Post by idle »

just use void.i unless you intend to pass in a var to initialize it
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Both are correct and do EXACTLY the same unless you used Define to change the default type.
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

*VOID is correctly, in my opinion.

Windows SDK:

Code: Select all

DWORD WINAPI ThreadProc(
  LPVOID lpParameter
);
LPVOID <-- Long pointer

This means it can be used to point to different types of (data-)objects.
But an integer argument is correct, as well. 'Cause integers has the same size than pointers.


Regards

Wolf
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

"void" isn't the same as "*void". "void" suggests that there are no parameters where "*void" is a void pointer (a pointer of no defined type).

*void in PureBasic would be the same as *Var.i (the default type in PureBasic is integer).
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

"void" isn't the same as "*void".
They generate the same assembly code (except for the name), so they are functionally the same.
Post Reply