I forgot to mention that the version of meta-trader that I am using is:
Interbank FX, LLC.
Version: 4.00 Build 220 (7 Nov 2008)
extern "C" __declspec(dllexport) int __cdecl unique345MyTestVoid() { return 2; } extern "C" __declspec(dllexport) int __cdecl unique345MyTestInt(int /*x*/) { return 1; }
will be more correct
extern "C" __declspec(dllexport) int __stdcall unique345MyTestVoid() { return 2; } extern "C" __declspec(dllexport) int __stdcall unique345MyTestInt(int /*x*/) { return 1; }
will be more correct
Thanks mql_coder.
I have tried the __stdcall protocol and it worked but but then I have to call the function using the name: "_<func>@<size>" so "unique345MyTestInit" becomes "_unique345MyTestInit@4" which is kind of unwieldy. This is what it looks like in the MQL4 code:
// Using the __stdcall protocol #import "C:\DATA\UNIQUE345.dll" int _unique345MyTestInt@4(int); #import print("contents = ",_unique345MyTestInt@4(10));
As I mentioned earlier, it works just fine but it looks rather strange and I still can't figure out why the crash would occur for "__cdecl".
I would be very happy if I could just call it using the "unique345MyTestInt" rather than the "_unique345MyTestInt@4" name but can live with this for now.
Do you know of other folks that have used Visual Studio 2003 to create DLLs for MQL4? Do I need to use a newer version?
Hello,
I have the same problem. I must call the function "_<func>@<size>". Can you say me please, how you solve the problem?
This is a question that should be answered by the user manual of your compiler. There almost certainly is a way to declare under which name a function should be exported. Some compilers for example seem to need this to be declared in a separate .def file. Read the manual of your compiler.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi:
I am hoping that someone can help me.
When I try to execute a simple function from a DLL that accepts an int argument, MQL4 crashes with no stack trace.
Here is the crash dump. As you can see, there is no stack trace but that is okay because I know exactly where it is happening. I just can't figure out why.
I have created the DLL using C++ in Visual Studio 2003 on a Microsoft XP Professional system (SP3, 32bit). It has two functions unique345MyTestVoid() and unique345MyTestInt(). The DLL module contents are shown below.
I created C++ program to verify that I can call LoadLibrary() and GetProcAddress() to correctly load and execute the functions. Everything works correctly.
When I create this simple MQL4 test script everything works:
But when I uncomment the unique345MyTestInt(5) line it crashes.
This is extremely befuddling. Any help would be greatly appreciated.
Thanks,
Joe