I'm currently programming a tcp/ip server using WSA. After some troubleshooting a friend of mine said that i should use bool __cdecl winsock_server ( void ) instead of bool winsock_server().
But he didn't explain to me what __cdecl and (void)
are doing. I already know that __cdecl changes the way how arguments are put on the stack on assembler level, but what does (void) mean?
I should point out that I'm new to C++. I only programmed in C# and VB.NET before.
Thanks in advance!
__cdecl
You got it right. It enforces function calling convention to c-style and thus the way function is called (How arguments are passed, who cleans stack). BTW this is already default calling convention.
(void) v/s ()
In C++ they are equivalent(no arguments).
In C however former means no arguments and latter means any number of arguments. So it can cause problems when you reuse the header file for C.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With