I have the following piece of code which I'm trying to understand. I know what this code does, but I don't get what each element mean. Can somebody please explain it to me?

typedef int(__stdcall * pICFUNC)(int, int);
pICFUNC add;
add = pICFUNC(lpfnGetProcessID);

Basically, this code allows me to prototype a function called add that takes two int parameters and returns an int too. The add function is within an external DLL file. But I want to understand each element.

The reason I ask is because the way the external DLL is coded defines the add function with __stdcall as well.

int __stdcall add(int x, int y);

But I want to remove the __stdcall part from my external DLL code. When I do that, and also remove the __stdcall from my typedef code as well, I get a bunch of errors which I don't understand.

You can not just arbitrarily remove __stdcall from the function prototypes because the DLL was compiled to use it. __stdcall is one of 5 calling conventions used by Microsoft (and probably others too) compilers. Here is a more in-depth thread about it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.