brutta storia...ho letto la maggior parte della pagina..e questo:
codice:
Summary
That's about it. In closure, I'll enumerate guidelines to keep in mind when creating C++ interface. You can look back on this as a reference or use it to help solidify your knowledge.
* All interface classes should be completely abstract. Every method should be pure virtual. (Or inline... you could safely write inline convenience methods that call other methods.)
* All global functions should be extern "C" to prevent incompatible name mangling. Also, exported functions and methods should use the __stdcall calling convention, as DLL functions and COM traditionally use that calling convention. This way, if a user of the library is compiling with __cdecl by default, the calls into the DLL will still use the correct convention.
* Don't use the standard C++ library.
* Don't use exception handling.
* Don't use virtual destructors. Instead, create a destroy() method and an overloaded operator delete that calls destroy().
* Don't allocate memory on one side of the DLL boundary and free it on the other. Different DLLs and executables can be built with different heaps, and using different heaps to allocate and free chunks of memory is a sure recipe for a crash. For example, don't inline your memory allocation functions so that they could be built differently in the executable and DLL.
* Don't use overloaded methods in your interface. Different compilers order them within the vtable differently.
mi piace poco..
allora ho capito che dovrei evitare di usare std::string ma devo usare char *
ma allora...se faccio una cosa del genere va bene?
//sto usando le stringhe, ma non le uso come passaggio di parametri
codice:
extern "C" struct comando{
char * cmd;
char * p1;
char * p2;
char * pNum;
char * pAgg;
};
extern "C" _declspec(dllexport) void foo(comando cmd)
{
std::string convert = cmd.cmd;
//etc
Sleep(200);
//blabla
}
In linea teorica direi che funziona, perché non interessa lo scambio di informazioni tra l'exe e la dll...inoltre ricordo che tempo fa...ahem..per fare una prova di dll iniection (sul mio pc), iniettai una dll che conteneva di tutto, nel senso di classi ed eredietarietà, funzioni static, funzioni virtual, eccezzioni e ovviamente std::string, vector, stringstream etcetcetc... e funzionava!
quindi penso che non devo usare elementi C++ solo quando passo da exe a dll o da dll a dll...ma all'interno della dll, posso fare quello che "voglio"
Mah, che ne pensi?