Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

How to use userData in DLL?

0 votes
284 views
I'm going to pass some complex customed data from one dll to another by using customed struct type, and I found a pointer called userData. There doesn't exist much documentation about how to use it. So, anyone can help me or give some example code?
asked Feb 18, 2021 by yaoyaoyao (15 points)

1 Answer

0 votes
I can provide an example, but the userData pointer is local to each DLL instance and cannot be passed between DLL blocks as you are intending.  The value of the userData pointer would be to retain data internal to each DLL between successive calls. The userData pointer should be used in place of global variables within a DLL.

If the pointer was passed between DLLs, the same issues that arise using globals in C scripts would occur (https://forum.plexim.com/3971/how-to-share-global-variable-in-different-c-script).

The best path forward is to create one DLL which integrates all your code or pass vectorized signals between DLL outputs and inputs.

Happy to provide more detailed information if you believe the userData functionality will be helpful in the common DLL approach.
answered Feb 19, 2021 by Bryan Lieblick (1,853 points)
edited Feb 22, 2021 by Bryan Lieblick
...