D
Daniel Schüle
Hello all,
I get the error when I try to compile this code
// .h file
typedef static int (*get)(void); // (*)
typedef static void (*set)(int); //
// .c file
// forward methods
static int getAMethod(void);
static void setAMethod(int);
static struct foo {
get getA;
set setA;
// and so on
}bar = {
.getA = getAMethod,
.setA = setAMethod,
};
// implement methods
static int getAMethod(void) { // do something with bar }
static void setAMethod(int value) { // the same }
-----------------------------
when I remove "static" in (*) then compiler (gcc3.3.5) accepts it
Is "static" not allowed in typedef declarations like this or why is the code
rejected?
And one more question ... suppose I would have
struct foo {
static get getA;
static set setA;
} bar;
what would be the semantic of the "static" in this context?
I come from C++, I dont know is this construct is allowed.
I only know for sure "const" would be ok there.
Thx for your answers
Regards, Daniel
I get the error when I try to compile this code
// .h file
typedef static int (*get)(void); // (*)
typedef static void (*set)(int); //
// .c file
// forward methods
static int getAMethod(void);
static void setAMethod(int);
static struct foo {
get getA;
set setA;
// and so on
}bar = {
.getA = getAMethod,
.setA = setAMethod,
};
// implement methods
static int getAMethod(void) { // do something with bar }
static void setAMethod(int value) { // the same }
-----------------------------
when I remove "static" in (*) then compiler (gcc3.3.5) accepts it
Is "static" not allowed in typedef declarations like this or why is the code
rejected?
And one more question ... suppose I would have
struct foo {
static get getA;
static set setA;
} bar;
what would be the semantic of the "static" in this context?
I come from C++, I dont know is this construct is allowed.
I only know for sure "const" would be ok there.
Thx for your answers
Regards, Daniel