DLL and acessing of Objects

Hello,

I have a fairly basic question.

I am creating a DLL using auto generated code.
There can only be one entry point function to the DLL. But in turn the entry point function should call other functions internally.
There is a structure object declared and defined as a global variable. But when i try to use the structure in my entry point function the DLL crashes.

How can i use the global struct objects in entry point and other internal functions? I tried to multiple ways, but none of them seem to work.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

(this is the global declaration - i do this is a Wrapper.h file)
RT_MODEL_TestDLL TestDLL_M_; // RT_MODEL_TestDLL is a struct
RT_MODEL_TestDLL *TestDLL_M = &TestDLL_M_;

(In Wrapper.cpp i call the following autogenerated function)

void MdlInitializeSizes(void)
{
  TestDLL_M->Sizes.numContStates = (0);/* Number of continuous states */
  TestDLL_M->Sizes.numY = (1);         /* Number of model outputs */
  TestDLL_M->Sizes.numU = (1);         /* Number of model inputs */
  TestDLL_M->Sizes.sysDirFeedThru = (1);/* The model is direct feedthrough */
  TestDLL_M->Sizes.numSampTimes = (1); /* Number of sample times */
  TestDLL_M->Sizes.numBlocks = (2);    /* Number of blocks */
  TestDLL_M->Sizes.numBlockIO = (0);   /* Number of block outputs */
  TestDLL_M->Sizes.numBlockPrms = (1); /* Sum of parameter "widths" */
}




Topic archived. No new replies allowed.