[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] calling function pointers via pointers ?

From: David Brown
Subject: Re: [avr-gcc-list] calling function pointers via pointers ?
Date: Thu, 29 Sep 2005 14:24:20 +0200

----- Original Message -----
From: "Vincent Trouilliez" <address@hidden>

> On Thu, 2005-09-29 at 09:25 +0200, David Brown wrote:
> > It's a little easier to follow than all this "void (*fp[])(void)" crap,
> > wouldn't you say?
> Thanks for pointing out that my code is crap ! ;-P

I didn't mean it personally, of course :-)  A lot of people, experienced and
inexperienced, fail to realise the importance of readability in their code.
I've forgotton how many years I've been programming C, yet I find an
expression like the one above difficult to parse without thinking about it.
One of the worst thing you can possibly write in a program is something
along the lines of:

    void (*fp[3])(void);        // fp is an array of three pointers to
void-to-void functions

It is far better to write things explicitly in the language when possible,
rather than as comments.

You've picked a chalenge with your complex menu structures, but you are
definitely going about it the right way.  Unconstrained arrays are almost
certainly the most elegant way to deal with the structures - when you figure
them out fully, you'll be glad you stuck by it.  Just take it slowly,
building your structure piece by small, understandable piece, with
carefully-named typedefs.



> I do mean it ! I mean, I am beginner... very motivated and eager to
> learn the art, but I can only do my best when laying a piece of code,
> and then I rely on the true experts on this list to correct me, so I can
> learn well, and fast. So, the more criticism and comments I get, the
> better and faster I can learn !
> Thanks everybody for all the advice and code/declaration examples, I
> will study all your posts and eventually lay a much improved menuing
> system for my application.
> There is one good thing of general interest that shines already through
> all your posts though, it is that "if it's too complicated, it's not
> right !".
> So I will watch myself and break things down, reorganise data types, as
> soon as a piece of code is getting overwhelming to read/understand/work
> on.
> Regards,
> --
> Vince, so much to learn...
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]