Section External, methods being optimized out
Jeremy Cowgar
jeremy at cowgar.com
Tue Aug 25 15:46:16 UTC 2009
We talked about this last November, but in the end never solved anything,
that I am aware of. Here's a real object (many slots removed for space
sake):
Section Header
+ name := BUTTON ;
Section Private
- action_block:{INTEGER};
Section External
- perform_action h:POINTER :INTEGER <-
( + b:BUTTON;
b := CONVERT(POINTER,BUTTON).on (`IupGetCallback(@h, "LISAAC_OBJ")`:POINTER);
b.action_block.value
);
Section Public
- set_action b:{INTEGER} <-
( + h:POINTER;
`
#if 0
`;
perform_action NULL;
`
#endif
`;
h := handle;
`IupSetCallback(@h, "ACTION", (Icallback) perform_action)`;
action_block := b;
);
Ok. See what I have to do with the #if 0 ? If I do not call
perform_action somewhere in my Lisaac code, then the resulting .c file
does not contain perform_action, even though it is used and referenced.
The problem is that it's used in a C block, not a Lisaac block.
Is there a better way of ensuring that "perform_action" doesn't get
optimized out or should I open a bug report as a feature request to scan
C code for external slots?
Now, thinking about this... Maybe the answer is simple? Why not just
output *all* slots in the External section? The resulting .c file will
be a bit larger, however, the C compiler will optimize out a function
that is not used anyway, so the resulting executable will be no
different.
--
Jeremy Cowgar <jeremy at cowgar.com>
More information about the Lisaac-devel
mailing list