Does a C block have knowledge of what step is being run?

Mike is correct that a dll global variable persists across steps. He is also correct that the global variable occurs only once in the same component. Therefore, if you have multiple instances of the same component in the sim, this global var is shared across instances.

I believe I solved the latest issue in my particular situation.

Here are code frags for that ‘fix’:

bool started = false; // sim started var

/**************************************************************/
extern “C” __declspec(dllexport) void compname(struct sLOGGER **opaque, double t, union uData *data)
{
… uData assignments …

if(!*opaque)
{
*opaque = (struct sLOGGER *) malloc(sizeof(struct sLOGGER));
bzero(*opaque, sizeof(struct sLOGGER));
}
struct sLOGGER *inst = *opaque;

// Implement module evaluation code here:
if(t == 0)
{ // Make sure we’re at the beginning of the sim/step.
if(started == false)
{ // Has not started yet
… Code to initialize at the first step
}
}
else
{ // t != 0
started = true; // signal the sim has started. This prevents reinitialization
}
… More code …
}

This method allows all instances of the same component to go through the initialization phase at t=0.
Once t no longer = 0 then the started var is set to true.

This method appears to work in my testing.

Len