R
Roman Mashak
Hello, All!
I would like to use this macro to substitute type of variable, but it
doesn't work by now:
typedef enum table_type_e {
INT,
FLOAT,
DOUBLE
} table_type_t;
#define TYPE(t) ((t == INT) ? int :\
(t == FLOAT) ? float :\
(t == DOUBLE) ? double : void )
int main()
{
.....
table_type_t t;
t = INT;
TYPE(t) p;
......
}
I'd like 'p' be has 'int' type. But during compilation I get this error:
parse error before "int" It points directly to "TYPE(t) p" string.
Am I breaking the standard or making some C-specific mistake?
PS. if it's important, I'm using gcc-3.2.2
With best regards, Roman Mashak. E-mail: (e-mail address removed)
I would like to use this macro to substitute type of variable, but it
doesn't work by now:
typedef enum table_type_e {
INT,
FLOAT,
DOUBLE
} table_type_t;
#define TYPE(t) ((t == INT) ? int :\
(t == FLOAT) ? float :\
(t == DOUBLE) ? double : void )
int main()
{
.....
table_type_t t;
t = INT;
TYPE(t) p;
......
}
I'd like 'p' be has 'int' type. But during compilation I get this error:
parse error before "int" It points directly to "TYPE(t) p" string.
Am I breaking the standard or making some C-specific mistake?
PS. if it's important, I'm using gcc-3.2.2
With best regards, Roman Mashak. E-mail: (e-mail address removed)