Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #21871

Re: interpret this code?

From "BartC" <bc@freeuk.com>
Newsgroups comp.lang.c
Subject Re: interpret this code?
Date 2012-06-05 14:42 +0100
Organization A noiseless patient Spider
Message-ID <jql2c2$efi$1@dont-email.me> (permalink)
References <30urs79vrgihohjaoca4g3bj1kfbcqa5jk@4ax.com>

Show all headers | View raw


"George" <gbeccles@verizon.net> wrote in message
news:30urs79vrgihohjaoca4g3bj1kfbcqa5jk@4ax.com...
> I'm working on an old (comment-free) program, and finding some of the
> code is above my pay grade.

Or possibly just below it. Code shouldn't be unnecessarily obscure. Not if 
someone else needs to make head or tail of it.

> I think the final result wants to be ...
>  const void (*ScrnFnc[])() = {
>    NullScrnFnc,
>    RYGScrnFnc,
>    ...
>    DefaultInitFnc,
>    LastNInitFnc,
>    ...
>  };
>
> Even assuming that's correct, I don't see how it gets there.  I see that
> SCRN_LIST/INIT_LIST will cause ea of their listed arguments (Null, RYG,
> etc) to instantiate the 'SCRN'/'INIT' macros in the ScrnFnc[]
> declaration,  But, ISTM, this would create something like (eg) ...
>  void (*NullFnc)()

I passed the code through a compiler option to generate the output of the
preprocessor (-E on gcc). The output, with editing to improve the layout,
is:

    const VOID_FNC ScrnFnc[] = {
     (const VOID_FNC)NullScrnFnc,
     (const VOID_FNC)RYGScrnFnc,
     (const VOID_FNC)Fr00ScrnFnc,
     (const VOID_FNC)LastNScrnFnc,
     (const VOID_FNC)DateTimeScrnFnc,
     (const VOID_FNC)DefaultInitFnc,
     (const VOID_FNC)LastNInitFnc,
     (const VOID_FNC)EvtLogInitFnc,
     (const VOID_FNC)EvtLogDetailInitFnc,
    };

Now why couldn't it have looked like that in the first place?

-- 
Bartc
 

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

interpret this code? George <gbeccles@verizon.net> - 2012-06-05 08:26 -0400
  Re: interpret this code? James Kuyper <jameskuyper@verizon.net> - 2012-06-05 09:19 -0400
    Re: interpret this code? Nick Bowler <nbowler@draconx.ca> - 2012-06-05 15:55 +0000
      Re: interpret this code? James Kuyper <jameskuyper@verizon.net> - 2012-06-05 12:05 -0400
  Re: interpret this code? "BartC" <bc@freeuk.com> - 2012-06-05 14:42 +0100
    Re: interpret this code? Noob <root@127.0.0.1> - 2012-06-05 16:19 +0200
  Re: interpret this code? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-06-05 14:43 +0100
  Re: interpret this code? Noob <root@127.0.0.1> - 2012-06-05 16:22 +0200
  Re: interpret this code? George <gbeccles@verizon.net> - 2012-06-05 22:50 -0400

csiph-web