Hi there
I need help with c++ string
I am MQL4 programmer
I know how to pass any value to dll and return it from my language
but the string value thats I cannot pass it from my DLL
so I need C++ function that I can put it in my dll to pass string from my MQL4 like e.g (Hello) the dll will compare this string with interior string like e.g (Hi There) if match it return 1; else return 0;
in my example (Hello) Dosent match (Hi There) so my function has to return 0
can any one make a small profject for this please?
thank you
ok thank you again
I tried to do it but I got error
error C2491: 'test' : definition of dllimport function not allowed
this error in mylip.cpp
I search it for this error but I cannot solved
can you help me
1 2 3 4 5 6 7 8 9 10
// mylib.cpp
#include "StdAfx.h"
#include "mylib.hpp"
bool MYLIB_API test(const std::string& str)
{
return (str == "Hi There");
}
// Here I Got This Error: error C2491: 'test' :
// definition of dllimport function not allowed
you need to compile with -DMYLIB_EXPORTS to define the MYLIB_EXPORTS flag.
When this flag is defined MYLIB_API is defined to be export, otherwise it's defined to be import. When you want to compile your dll you usually want it to be exported.
thank you
I tried to do it but still cannot do it because I am not a profissional c++. I will wait if somebody can make as full small project and upload it for me.
thank you again
ust return the result of the comparison return test(str)==test(str1);
this solved that error
you are on windows, right?
I don't know why that should make a difference, you still compile the same chunk of code, you don't get to the else branch on windows anyway