03-15-2007 03:44 PM
Hello,
I’m trying to generate a function tree from a header file but I'm getting an “Unknown data type” error in a function declaration taking a typedefed parameter. Please let me know what I’m doing wrong.
typedef enum
{
FIRST,
SECOND
}MY_ENUM;
/// ENUM MY_ENUM
#define FIRST
#define SECOND
int dllexport __cdecl myFunc( int param1, MY_ENUM param2);
Thanks for any help or suggestions,
Joe
03-15-2007 05:40 PM
typedef enum
{
FIRST, // FIRST
SECOND // SECOND
} MY_ENUM;
/// ENUM MY_ENUM
#define FIRST
#define SECOND
int dllexport __cdecl myFunc( int param1, MY_ENUM param2);
Let me know if this doesn't work for you. Using enums in header files can be a littel tricky. I would check out Generate Function Tree CVI Help (Help >> Contents; Switch to the Index tab and type "Generate Function Tree") to see the rules for header files.
Best Regards,
03-15-2007 08:16 PM
03-16-2007 08:46 AM
03-28-2007 02:04 PM
Hello again Jonathan,
I finally got back to this and tried again. I was still getting "unknown data type" at the function declaration that takes the enum parameter, until I changed this:
typedef enum
{
FIRST, // myFirst
SECOND // mySecond
}MY_ENUM;
to this:
typedef enum
{
FIRST, // myFirst
SECOND // mySecond
} MY_ENUM;
^
Apparently the Function Tree tool is extremely finicky about placement of white space. It also chokes on "int* my_int_ptr", which has to be "int *my_int_ptr".
Now I'm trying to figure out how to format a function declaration that takes a pointer to a function as a parameter. I've tried every placement of white space I can think of and am still getting "The parameter type is not a valid identifier", e.g.:
int my_func( int ( *func_ptr)( int *));
Thanks,
JoeN
03-30-2007 08:54 AM
03-30-2007 09:34 AM
Hi James,
Thanks very much for your help.
FWIW, I'm using LW/CVI version 7.1.1, and that statement isn't in my version of Help at the place you cited. There is only one mention of white space, ("LabWindows/CVI preserves white space from the header file to the generated header file"), and no instance of the word "asterisk".
Maybe someday my employer will spring for the latest version
I worked around the pointer-to-function issue by putting the args in a struct and passing that.
Thanks again,
JoeN
03-30-2007 10:40 AM
Hi Joe,
We added more information about rules for using the Generate Function Tree
command in LabWindows/CVI 8.0. Therefore you wouldn't have that text
snippet that James mentioned in the help.
To address your question, you need to do several things. First off you need to
make sure that you have defined your function pointer prototype in your header
file prior to using it. Secondly, you need to use the /// ADDT tag to add your
"function pointer" type to the function panel. If you don't use this
tag, you would get an error like "unknown data type". So you would
say something like
// Define your function pointer prototype
typedef int (*func_ptr)(int *);
/// ADDT func_ptr
// using the type
int DLLEXPORT my_func(func_ptr value);
Hope this helps!
Best Regards,