|
From where are you calling the function ? Something like VB ?
You need to change the calling convention to __stdcall.
Put some code if you want more information.
|
|
|
|
|
Check the calling convention of function.
|
|
|
|
|
trioum wrote: This is usually a result
of calling a function declared with no calling convention with a function pointer declared
with a different calling convention
Isn't it clear? Your (calling) code probably use a calling convention that doesn't match the one DLL function expects.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
I am using the MSvc++ to call the dll
I call the function as follows
I defined the function in dll as follows
extern "C" __declspec(dllexport) int Adddata(void* item);
DllMain()
{
}
int Adddata(void* item)
{
//some processingen here
}
in my test.exe i called as follows
struct _data
{
// some fields;
}
onButtonclick()
{
struct _data *data = (struct _data*)malloc(sizeof(struct _data ));
//some inityialization code here
data->someintvalue;
strcpy(data->somecharvlaue,"hfd");
//
int rvalue = Adddata(data); // dll function called
--here the debug error come---------
}
Trioum
|
|
|
|
|
Uhm... Seems a dynamic memory handling issue. Could you please post the code details (i.e. the actual struct definition, its initialization, the Adddata function implementation)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
due to code security issue I cannot send the details of the Adddata function in open forum.
I am sure no error in that function and returning well the rvalue .
Trioum
|
|
|
|
|
Well, good luck.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
good luck but why I am still facing the same problem
Trioum
|
|
|
|
|
No code, no help: Sorry I have my CPMRU (C ode P roject M ind R eader U nit) out of order today.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
trioum wrote: I defined the function in dll as follows
How is it declared in your exe ? Because that's just the part in the dll. Is it in the same file with precompiled directives (#ifdef...)
How do you load the dll ? Is it using LoadLibrary/GetProcAddress or linking to a static library ?
You need to provide more information if you want a solution.
|
|
|
|
|
I am linking to a static library and I defined it in exe as follows
extern "C" __declspec(dllexport) int Adddata(void* item);
Trioum
|
|
|
|
|
trioum wrote: extern "C" __declspec(dllexport) int Adddata(void* item);
No, that's in the dll: you have dllexport, you should have a dllimport for the exe. Where is this line of code ? In which file ? Show the code of this header file.
Did you make a search on google about calling conventions ?
Sorry, but if you are so sparse about giving informations, there's no way for us to help you.
|
|
|
|
|
sorry sir I typed wrong due to hurry it is dllimport i.e.
extern "C" __declspec(dllimport) int Adddata(void* item);
Trioum
|
|
|
|
|
now I tested another function that is working fine but not previous one
the new function as follows
defined in dll as
extern "C" __declspec(dllexport) int testfunction();
dllmain()
{
}
int testfunction()
{
return 2;
}
in my .exe it is as follows
extern "C" __declspec(dllimport) int testfunction();
onButtonclick()
{
int rvalue = testfunction();
//above code return rvalue is 2 and no error
}
Adddata(void* item); still firing same debug error
Trioum
|
|
|
|
|
That's normal: you don't pass any arguments to the function, so there's no cleaning of the stack for the arguments. So, calling convention has no effect here.
Try something: comment everything that is inside the Adddata function (in your dll). If you don't have the crash, then it probably means that you have a bug in your function.
|
|
|
|
|
trioum wrote: how can I solve it.
At a minimum, you could Google for (parts of) the error message.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, i need your help
I want to use MapWinGIS (http://www.mapwindow.org/mapwingis.php) in my MFC application. (dialog box)
So I add in my project a Windows form where i develop the MapWingis.
(public __gc class libControl : public System::Windows::Forms::Form .... )
...
I succeed to open the windowform with a button, but I want the windowsForm is encrusted in my dialog box. Like it is a simple static.
Do you know how I can do that?
how can Integrate Windows Forms Into my MFC Applications... like that http://www.codeguru.com/cpp/cpp/cpp_managed/interop/print.php/c14589[^]
Thanks
|
|
|
|
|
Is this a Managed C++ question?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Managed C++ and MFC question... i don't know exactly where can i ask the question.
i want know how can i use managed code in an unmanaged code.
how integrate a WindowsForm like a simple control in my dialog box.
|
|
|
|
|
ellipsev2 wrote: i don't know exactly where can i ask the question.
Is this not the right forum?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ellipsev2 wrote: how integrate a WindowsForm like a simple control in my dialog box.
Always check out the articles here on CodeProject [^]when you have a general question like that
led mike
|
|
|
|
|
yes led mike, it's ok for a simple WinForm control, but i want integrate a Form
I will see what you says DavidCrow, sorry fot the mistake
|
|
|
|
|
Is it possible to add a user defined button inside a AfxMessageBox??
Like the message box should display 2 buttons - a 'OK' and 'ADD' button. When the user cliks ADD it should call some userdefined function.
Priya Sundar
|
|
|
|
|
AfxMessageBox is just a wrapper around the MessageBox function. If you look at that, then there is no parameter for changing button names.
There is a new SDK function in Vista for simple message boxes, something like promptbox, but I'm too lazy to search, and it would be vista only.
There's nothing stopping you writing your own dialog with a bit of text and buttons - and with the text in a resource, it would be more internationalisable at a later date anyway.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|