G
George
I'm working on an old (comment-free) program, and finding some of the
code is above my pay grade. I'd appreciate insight into what's going on
with the segment below.
-----------------
#define SCRN_LIST \
SCRN(Null) \
SCRN(RYG) \
SCRN(Fr00) \
SCRN(LastN) \
SCRN(DateTime) \
#define INIT_LIST \
INIT(Default) \
INIT(LastN) \
INIT(EvtLog) \
INIT(EvtLogDetail) \
typedef void (*VOID_FNC)(void);
#define SCRN(symm) (const VOID_FNC)symm##ScrnFnc,
#define INIT(symm) (const VOID_FNC)symm##InitFnc,
const VOID_FNC ScrnFnc[] = {
SCRN_LIST
INIT_LIST
};
#undef SCRN
#undef INIT
// typical fnc
void
NullScrnFnc(void) { ... }
-----------------
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)()
Bonus points: I don't know how to 'read' the VOID_FNC typedef. I think
that's a standard construct (ptr to void fnc?), but the logic of it
eludes me.
Thanks,
George
code is above my pay grade. I'd appreciate insight into what's going on
with the segment below.
-----------------
#define SCRN_LIST \
SCRN(Null) \
SCRN(RYG) \
SCRN(Fr00) \
SCRN(LastN) \
SCRN(DateTime) \
#define INIT_LIST \
INIT(Default) \
INIT(LastN) \
INIT(EvtLog) \
INIT(EvtLogDetail) \
typedef void (*VOID_FNC)(void);
#define SCRN(symm) (const VOID_FNC)symm##ScrnFnc,
#define INIT(symm) (const VOID_FNC)symm##InitFnc,
const VOID_FNC ScrnFnc[] = {
SCRN_LIST
INIT_LIST
};
#undef SCRN
#undef INIT
// typical fnc
void
NullScrnFnc(void) { ... }
-----------------
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)()
Bonus points: I don't know how to 'read' the VOID_FNC typedef. I think
that's a standard construct (ptr to void fnc?), but the logic of it
eludes me.
Thanks,
George