This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Constructing Function Calls
- To: "Pierre NGUYEN-TUONG" <pierre dot nguyen-tuong at lip6 dot fr>, <help-gcc at gnu dot org>
- Subject: Re: Constructing Function Calls
- From: "John Love-Jensen" <eljay at adobe dot com>
- Date: Wed, 10 Oct 2001 14:06:49 -0500
- References: <3BC492D8.9020601@lip6.fr>
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