Page 1 of 1
functionname(void) or functionname(*void)
Posted: Tue Apr 21, 2009 5:33 am
by funnyguy
When writing a function for a thread which one is correct? functionname(void) or functionname(*void)?
Posted: Tue Apr 21, 2009 6:04 am
by idle
just use void.i unless you intend to pass in a var to initialize it
Posted: Tue Apr 21, 2009 9:52 am
by Trond
Both are correct and do EXACTLY the same unless you used Define to change the default type.
Posted: Tue Apr 21, 2009 11:19 am
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
Posted: Wed Apr 22, 2009 8:19 am
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).
Posted: Wed Apr 22, 2009 2:00 pm
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.