Constructing Function Calls
John Love-Jensen
eljay@adobe.com
Wed Oct 10 12:14:00 GMT 2001
Hi Pierre,
The problem is that C or C++ are not good languges to do what you want to
do. Pick a better language, like LISP or Perl.
Otherwise, package your parameter data better, such as:
typedef enum { kEndOfList, kString, kChar, kInt, kFloat, kDouble } Datum_t;
// Whatever you're interested in
struct Datum {
Datum_t mType;
void* mData;
};
void function_B(Datum* DataList)
{
while(DataList->mType != kEndOfList)
{
switch(DataList->mType)
{
case kString: printf("--- %s\n", (char*)(DataList->mData));
break;
case kChar: printf("--- %c\n", *(char*)(DataList->mData));
break;
case kInt: printf("--- %d\n", *(int*)(DataList->mData)); break;
case kFloat: printf("--- %f\n", *(float*)(DataList->mData));
break;
case kDouble: printf("--- %lf\n", *(double*)(DataList->mData));
break;
default: print("--- Danger, Will Robinson!\n");
}
++DataList;
}
}
I'll leave the packaging up of your data as an exercise.
Sincerely,
--Eljay
More information about the Gcc-help
mailing list