Are there any tutorials on defining a variable so that it can be used for any type. Example the following:

int main() {

var myvariable;
myvariable="this is a test";
myvariable=3.141592;
myvariable=myvariable*myvariable;

return 0;
}

But I don't know how to make it possible to make the above code possible. It is mainly so I can forward the last parameters of the fprintf and fscanf function in a dll function but would be useful for other things too. Does anybody know how to define a mixed variable?

Does anybody know how to define a mixed variable?

There's not such a thing as mixed variable.
Variable overloading does not exist in the C language.

Then how did the php written in C managed to get mixed variables in it's syntax? There must be a way because I have a function but any type of variable can be inserted into each of the function parameters which makes it impossible to define. Example, the following:

DLLEXPORT int fprintf_(FILE *stream, const char *format,  char a[]="", char b[]="") {
return fprintf(stream, format, a, b);
}

The only problem with the above code is that the last two parameters can be any type of variable. I have seen such thing done in the open source php written in C but am not good at understanding large complex source but I just don't know how. Any suggestions?

I managed to make the following but I can't seem to slot the DLLEXPORT in there.

#define DLLEXPORT extern "C" __declspec ( dllexport )
#define var(variable)    \
{                        \
    return variable;     \
}

With the above method it should be possible to define a function with unknown variable types but I just need to know how I can slot in the DLLEXPORT so the function will be exported into the dll. I tried the following but got a fatal error when trying to use the dll:

#define DLLEXPORT extern "C" __declspec ( dllexport )
#define var(variable) DLLEXPORT    \
{                                  \
    return variable;               \
}

Any ideas?

This article has been dead for over six months. Start a new discussion instead.