08-10-2010 10:32 PM
I have a VI that takes an ENUM as an input to select a command to be performed. This VI is part of a DLL to be called from C.
I would like to see the ENUM definition in the header file for the DLL so that the C program can use the same symbolic names for the commands that I
am using in my case selector within the VI.
Is there a good way to do this?
When I generate the DLL the parameter is shown simply as a uint32_t (I have the ENUM defined as 32 bit in LV rather than the default 16 bit).
I would have expected that all ENUMs that are parameters or return values of any function going into a DLL would automatically be defined in the DLL's header...
They really should be typedef ENUM definitions with the name of the LV control being given to the typedef by default.
Any help is greatly appreciated.
Thanks,
Klaus
08-10-2010 11:19 PM
You can export all items from an Enum Control using the "Strings[]" property. The values for enums always begin with zero and increment by one.
Does this help?
08-10-2010 11:41 PM
Thank you for the suggestion.
I know how to get the string values from the enum in LV itself, just like you have shown.
I also know that I could write a VI that does that and writes it to a file, reformat it as a C enum, etc...
However I think that would be a hack.
For one, the function prototype in the DLL should not be an unsigned int, but an enum, so I would have to manually change the header file or write a script of sorts.
Also, the LV DLL builder should really be smart enough to extract the enum definition and include it as a proper C typedef enum.
So, I guess my question is, is there a way to do this using some settings in the build specifications for the DLL and if not why not?
Klaus
08-11-2010 08:57 PM
The automatic header files generated by the dll build spec are never very smart - I almost always end up replacing it with my own customized version (especially when using clusters/struct -TD1, TD2 etc are never meaningful names, no matter what the language)