array of pointer to function support in GNU C

2010-09-15 Thread ir_idjit

i've been writing bits of codes where it requires to have an array or
"pointers to functions", so the decision of which function to execute is
indexed... (i know, a lot of you will say "well, that's a VERY specific of a
solution, there's always the problem of binary compatibility when passing
arguments for different argument-taking functions, blah, blah, blah... just
rely on good old fashioned function calls with conditional statements..."
but, pls, forget about that sort of incompatibility...)

even if i hadn't tried it in C++, i know it should work as i've seen some
examples posted on the net. but i'm trying to write my code in GNU C, so it
could be compiled by GCC -- god knows i would never try to compile it in GNU
C++; that gargantuan thing

but whatever i do it i just can't get it to work
code:

some_header.h:
static void *(*oper_table)(void **);



main.c:
int main(void)
{
oper_table[0]; /* just a test. data is not used or modified*/
return 1;
}

error: subscripted value is pointer to function




whereas:
int main(void)
{
void *(*func)(void **);
func;
return 1;
}

compiles just fine

i do realize that i'm depending on dialect-specific features, so i don't
even know if this is supported on my gcc as of version 4.3.3. if it's not a
dialect problem, then this stumps me even more.
-- 
View this message in context: 
http://old.nabble.com/array-of-pointer-to-function-support-in-GNU-C-tp29725303p29725303.html
Sent from the gcc - Dev mailing list archive at Nabble.com.



passing #define-d values to #define-d macros

2010-09-26 Thread ir_idjit

i can seem to get this to work:

#define PREFIX "p_"
#define HIGHER_INTERFACE(id) LOWER_INTERFACE(PREFIX, id)

#define LOWER_INTERFACE(prefix, id) struct prefix##id \
{ \
int i; \
}

int main(void)
{
HIGHER_INTERFACE(0);

/* test if struct declaration went well: */
struct p_0 var;
return 0;
}




when i compile with gcc 4.3.3 it says:
"error: storage size of 'var' isn't known"

i know c preprocessor has MANY shortcomings (or maybe it isn't, maybe those
were supposed to be handled by the development environment's make system)...
but if you're writing libraries that can be easily ported to many system
with VERY LITTLE modification, shouldn't this tiny functionality been
adressed?? an escape character would've been nice
-- 
View this message in context: 
http://old.nabble.com/passing--define-d-values-to--define-d-macros-tp29815182p29815182.html
Sent from the gcc - Dev mailing list archive at Nabble.com.



Re: passing #define-d values to #define-d macros

2010-09-26 Thread ir_idjit

drives me crazy that i can't get his to work
-- 
View this message in context: 
http://old.nabble.com/passing--define-d-values-to--define-d-macros-tp29815182p29815215.html
Sent from the gcc - Dev mailing list archive at Nabble.com.