Unfortunately, C does not support templated functions or function overloading. If you need a function to accept input of an unknown type, you can use a variable argument list:
int Foo (int type, ...);or declare the parameter a
void *:
int Foo (int type, void *value);However, in either case, there is no builtin way of discerning the type of value that was actually passed. This is why the
type parameter is needed; this additional parameter makes it clear what type was actually passed. This is how the
Get/SetXXXAttribute functions in the CVI libraries work (the attribute parameter disabiguates the unknown type).
Using a variable argument list is probably a better option than a
void * for input values because it does not require any extra work for the caller. If you're not familiar with writing functions that take variable argument lists, take a look in a C reference or search the internet for
va_list, va_start, va_arg, and
va_end. That should give you a good start.
If you have any problems, I'd be happy to help.
Mert A.
National Instruments