DLL Global Variables Preserved?

@Engelhardt

From today’s revision history: “12/31/2023 .DLL global variables are now preserved from .step to .step”.

Does this mean that C-Block DLL’s are now loaded / unloaded only at the start / end of the simulation run? (I’m not sure how else you’d retain DLL globals. Maybe not call DllMain() between steps?)

Do I correctly assume that we will get Destroy() calls at the end of each step to allow freeing per-instance allocations between steps? Or is there some other mechanism?

Or am I totally misunderstanding the revision comments / implications?

–robert

1 Like

Robert,

I’ve tested this new feature in C-block dlls. You can create a Global var in the module and it keeps the last known value in the var across steps. For example, this persistence across steps allows me to determine the first step is being executed. This solves Does a C block have knowledge of what step is being run?

The var is destroyed once the sim ends.

Len

Thanks, Len. That’s not exactly what I was getting at.

–robert

Len, I’ve posted a link to code for a more robust approach to “knowing what step is being run” in the thread that you referenced above. Just FYI.

–robert