I
Ico
Hello,
(My apologies if discussing C99-features is not appropriate in this
newgroup)
I'm trying to build a state machine in C99 using nested functions. This
is for a certain embedded architecture for which my compiler is not
particulary good at optimising switch() statements.
The code flow is basically something like this:
int main(void)
{
void (*p)(void);
void one(void)
{
p = two;
}
void two(void)
{
p = one;
}
p();
p();
}
This will not compile howver, because the function two() is not known from
within function one(). My first attempt would be to simple add a
prototype for two(), but this not seem to be possible according to my
compiler (Which happens to be gcc)
Is the above construct possible ?
Thank you,
(My apologies if discussing C99-features is not appropriate in this
newgroup)
I'm trying to build a state machine in C99 using nested functions. This
is for a certain embedded architecture for which my compiler is not
particulary good at optimising switch() statements.
The code flow is basically something like this:
int main(void)
{
void (*p)(void);
void one(void)
{
p = two;
}
void two(void)
{
p = one;
}
p();
p();
}
This will not compile howver, because the function two() is not known from
within function one(). My first attempt would be to simple add a
prototype for two(), but this not seem to be possible according to my
compiler (Which happens to be gcc)
Is the above construct possible ?
Thank you,