typedef int ( *ffp )( float ); //why are there two?
test()
{
ffp fp = (ffp)myex;
}
can this same code be written as:
typedef int (*ffp, float);
test()
{
ffp fp = (ffp)myex;
}
????
typedef int ( *ffp )( float ); //why are there two?
test()
{
ffp fp = (ffp)myex;
}
can this same code be written as:
typedef int (*ffp, float);
test()
{
ffp fp = (ffp)myex;
}
????
I don't think so. It looks like your code is casting a value twice (using old C-style casts) to get the correct type.
typedef int ( *ffp )( float ); //why are there two?
this is making a type called 'ffp' which is a pointer to a function that has one argument that is of type float, and returns an int.
the use of the two sets of parenthesis make it easier to read, and it's the proper way of declaring a pointer to a function
hope that helps
U.
Quidquid latine dictum sit, altum sonatur.
Whatever is said in Latin sounds profound.
>the use of the two sets of parenthesis make it easier to read
That too, but the biggest reason is that without the parens it's no longer a function pointer. Take these two declarations for example:
int ( *fp ) ( float );
int *fp ( float );
The only difference is the lack of parens, but the declarations are completely different. The first declares fp, a pointer to a function that takes a float as an argument and returns int. The second declares a function called fp that takes a float as its argument and returns an int pointer. The second is like saying:
int *( fp ) ( float );
Which doesn't work since the * binds to the return type instead of the function identifier.
Just elaborating on your answer Uraldor.
-Prelude
My best code is written with the delete key.