Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do __cdecl and (void) mean?

Tags:

c++

void

cdecl

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!

like image 376
AcrimEx Avatar asked Oct 16 '25 08:10

AcrimEx


1 Answers

__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.

like image 65
Gyapti Jain Avatar answered Oct 18 '25 21:10

Gyapti Jain