01-16-2020 07:59 AM - edited 01-16-2020 08:04 AM
@Deep33 wrote:
Thanks all. U32 is working.
Basically what we are doing is LabVIEW-C interaction.Suppose when we want to speak from C to LabVIEW, C will Generate an user event that is registered in LabVIEW. So to Generate the user event, C has to know the User Event Reference Number.
This is just a brief idea about what we are trying to achieve.
You don't need to typecast the refnum for that. You can configure the Call Library Node parameter to Adapt to Type. When you then let LabVIEW create the C code you will see something like this:
int32_t MyUserEventInstaller(LVUserEventRef *userEvent, .....)
{
/* Now you can store the user event refnum somewhere where the C code can reference it later on by calling PostLVUserEvent(m_Event, data); */
static LVUserEventRef m_Event = *userEvent;
/* Obviously a flexible and scalable solution will not store the event refnum in a static variable but somewhere in a context, object or similar that is also passed to the specific functions somehow such as by a handle */
}
Technically a LabVIEW refnum is indeed an uInt32 value but there is no need to specifically use that. The LVUserEventRef declaration in extcode.h makes sure that the correct type is used even if LabVIEW 2028 may suddenly decide to make this something else instead for instance to support some new 128-bit hardware architecture. 😀
If you use uInt32 instead you make your code depend on assumptions that are unneccessary and that make your code less maintainable in the future. And you need the extcode.h include anyhow for the declaration of the PostLVUserEvent() function.