Click here to Skip to main content
16,004,602 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Date receiver Pin
David Crow26-Aug-05 3:55
David Crow26-Aug-05 3:55 
GeneralRe: Date receiver Pin
Maximilien26-Aug-05 4:13
Maximilien26-Aug-05 4:13 
Questioncaling conventions Pin
Member 222581226-Aug-05 1:29
Member 222581226-Aug-05 1:29 
AnswerRe: caling conventions Pin
Cedric Moonen26-Aug-05 1:55
Cedric Moonen26-Aug-05 1:55 
GeneralRe: caling conventions Pin
toxcct26-Aug-05 2:26
toxcct26-Aug-05 2:26 
GeneralRe: caling conventions Pin
Cedric Moonen26-Aug-05 2:36
Cedric Moonen26-Aug-05 2:36 
GeneralRe: caling conventions Pin
Member 222581226-Aug-05 3:00
Member 222581226-Aug-05 3:00 
GeneralRe: caling conventions Pin
MailtoGops26-Aug-05 3:19
MailtoGops26-Aug-05 3:19 
Hi,

__cdecl is differs from other calling conventions. __cdecl is used for C calling convention.

To be clear about the stack clean up assume the following senario.

In "C", we have an option to pass variable number of parameters to a fucntion.

Generall the function would be defined a

void Add(...)
{
}

you can call this function like

void main()
{
Add(10);
Add(10,20,30);
}

In the above case , caller knows how many parameter is passed to that Add function. Add() function has no clue about how many parameter has been passed to it. In this case Add() function cannot not do stack clean up, becasue it has no clue how many paramter passed ..

Hence here is, caller responsibe to clean up the stack of Add() function, because it knew how many parameter had been passed...

But in case of __stdcall convetion, there are a lot of articles in codeproject, net, usenet available. __stdcall forces that the number of parameter passed to a function must be defined so that the called function can do clean up the stack.


In your code, you have declared a function pointer which is not __stdcall specified. But the funtion you calling is using __stdcall convention. You are calling that function using a function pointer. According to your compiler, you function pointer is following __cdecl because no calling convention specified in your code.

(*fun) ( );

When you call the function, as per __stdcall standard, your called function will do stack clean up. Hence stack is already cleaned...

In the next line, now the caller responsiblity to do clean , because your declaration says your function pointer is follwoing __cdecl convention which mean caller has to clean up the stack.. So the caller tried to clean up not existing stack (Becuase it is already cleaned), hence an error.


Hope you understand this











" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "

- Words from Nelson Mandela

Thanks & Regards,

Gopalakrishnan
GeneralRe: caling conventions Pin
David Crow26-Aug-05 3:22
David Crow26-Aug-05 3:22 
QuestionHow to get HWND of my application window ? Pin
Amarelia26-Aug-05 1:08
Amarelia26-Aug-05 1:08 
AnswerRe: How to get HWND of my application window ? Pin
Jack Puppy26-Aug-05 1:41
Jack Puppy26-Aug-05 1:41 
AnswerRe: How to get HWND of my application window ? Pin
MailtoGops26-Aug-05 3:28
MailtoGops26-Aug-05 3:28 
QuestionCmdUpdateUI Pin
Joel Holdsworth26-Aug-05 1:05
Joel Holdsworth26-Aug-05 1:05 
AnswerRe: CmdUpdateUI Pin
Roger Allen26-Aug-05 2:45
Roger Allen26-Aug-05 2:45 
AnswerRe: CmdUpdateUI Pin
David Crow26-Aug-05 3:13
David Crow26-Aug-05 3:13 
GeneralRe: CmdUpdateUI Pin
Joel Holdsworth26-Aug-05 4:39
Joel Holdsworth26-Aug-05 4:39 
GeneralRe: CmdUpdateUI Pin
David Crow26-Aug-05 4:48
David Crow26-Aug-05 4:48 
GeneralRe: CmdUpdateUI Pin
Joel Holdsworth29-Aug-05 22:20
Joel Holdsworth29-Aug-05 22:20 
GeneralRe: CmdUpdateUI Pin
Joel Holdsworth29-Aug-05 23:22
Joel Holdsworth29-Aug-05 23:22 
QuestionDynamically allocated strings Pin
Anonymous26-Aug-05 0:40
Anonymous26-Aug-05 0:40 
AnswerRe: Dynamically allocated strings Pin
Bob Ciora26-Aug-05 1:08
Bob Ciora26-Aug-05 1:08 
GeneralRe: Dynamically allocated strings Pin
Cedric Moonen26-Aug-05 1:13
Cedric Moonen26-Aug-05 1:13 
GeneralRe: Dynamically allocated strings Pin
sunit526-Aug-05 1:09
sunit526-Aug-05 1:09 
AnswerRe: Dynamically allocated strings Pin
oleg6326-Aug-05 4:38
professionaloleg6326-Aug-05 4:38 
QuestionCStatic Pin
Nishad S26-Aug-05 0:35
Nishad S26-Aug-05 0:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.