A quick question on how danagerous this would actually be...
In a static library i have this function that will be the starting base for my engine.
_declspec(dllexport) struct EngineAPI {
public:
EngineAPI();
~EngineAPI();
EngineAPI *Create();
private:
};
//-- EngineAPI.cpp
EngineAPI *EngineAPI::Create() {
EngineAPI *engine = new EngineAPI();
return engine;
}
//-- In Dynamic Library to be interpoled in C#.
EngineAPI *gEngine;
void CreateEngine() {
gEngine = gEngine->Create();
if(gEngine == nullptr) {
//-- we have problem
}
else {
//-- We are good to go.
}
}
I just want to know because it's working for me but on this other question\answer forum they literally jumped on me saying that code was dangerous and absolutely horrendous. I'm just wanting to know why they would consider that?