Below some example of a simple program (WinApi), some code ommited.
//scdll.h header because this example uses dynamic dll loading
#include "../sc/scdll.h"
...
SCINITPROC SCInit = NULL;
SCDEINITPROC SCDeinit = NULL;
SCGETENVPROC SCGetEnv = NULL;
HMODULE libHandle = NULL;
int main(int argc, char* argv[])
{
//opening dll
libHandle = LoadLibrary("../lib/scdll.dll");
if(!libHandle)
return -1;
//entry point procedures, must be always initalized
SCInit = (SCINITPROC) GetProcAddress(libHandle, "SCInit");
SCDeinit = (SCDEINITPROC) GetProcAddress(libHandle, "SCDeinit");
SCGetEnv = (SCGETENVPROC) GetProcAddress(libHandle, "SCGetEnv");
if(!SCInit || !SCDeinit || !SCGetEnv)
return -1;
//using default functions from auxiliary header, they write formatted error
//to default output
ISCEnvDesc envDesc;
envDesc.compileErrorCallback = SCAUXDefaultCompileErrorCallback;
envDesc.envErrorCallback = SCAUXDefaultEnvErrorCallback;
//Calling SCInit to get environment object
ISCEnv *env = SCInit(&envDesc);
if(!env)
return -1;
//use library
...
//clearing environment
SCDeinit();
//free dll
FreeLibrary(libHandle);
return 0;
}
See example ex_dllInit to see how to use dll.