A
Andy Lomax
gcc 3.3 allowed a typedef for a function pointer to contain default
argument specifications; for example:
typedef int (*foo) (int, int, int=0, bar=0);
However, it turns out that this is illegal and gcc 3.4 prohibits it.
Problem: I've got a lot of code that uses this 'feature', and I can't
move the default specifications into the function declaration or
definition, because they're not visible. This means that I can no
longer call foo-type functions without supplying all the arguments,
which is causing me problems. In addition, I can't even find a
workaround that compiles.
The current situation is that I have a library which has:
typedef int (*foo) (int, int, int=0, bar=0);
class A {
...
foo user_func;
A(foo user_func_) :
user_func(user_func_) {...}
};
The library user supplies 'user_func_', and I call 'user_func' in the
library code with a variable number of parameters, using the defaults.
Within the library itself, there are no user_func declarations or
definitions.
The only potential fix I can see is to manually expand out all the
typedefs, but this doesn't work. I would have to write:
class A {
...
int (*user_func) (int, int, int=0, bar=0);
A(foo user_func_) :
user_func(user_func_) {...}
};
gcc doesn't allow this, because I'm declaring a pointer, and not a
function, and so I can't supply defaults.
Any ideas?
Cheers -
AL
argument specifications; for example:
typedef int (*foo) (int, int, int=0, bar=0);
However, it turns out that this is illegal and gcc 3.4 prohibits it.
Problem: I've got a lot of code that uses this 'feature', and I can't
move the default specifications into the function declaration or
definition, because they're not visible. This means that I can no
longer call foo-type functions without supplying all the arguments,
which is causing me problems. In addition, I can't even find a
workaround that compiles.
The current situation is that I have a library which has:
typedef int (*foo) (int, int, int=0, bar=0);
class A {
...
foo user_func;
A(foo user_func_) :
user_func(user_func_) {...}
};
The library user supplies 'user_func_', and I call 'user_func' in the
library code with a variable number of parameters, using the defaults.
Within the library itself, there are no user_func declarations or
definitions.
The only potential fix I can see is to manually expand out all the
typedefs, but this doesn't work. I would have to write:
class A {
...
int (*user_func) (int, int, int=0, bar=0);
A(foo user_func_) :
user_func(user_func_) {...}
};
gcc doesn't allow this, because I'm declaring a pointer, and not a
function, and so I can't supply defaults.
Any ideas?
Cheers -
AL