We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
// Hi,
//first: create a function typedef of void(void) typedef void(*myFunctionType)(void);
//second: declare some functions void vTst000(void){} void vTst001(void){} void vTst002(void){}
//third: create pointers to these functions myFunctionType pntTst000=vTst000; myFunctionType pntTst001=vTst001; myFunctionType pntTst002=vTst002;
// My question is this: // // Is it ALWAYS true when comparing two pointers to two different functions // that the pointer belonging to the LATER declared function always contains // a HIGHER (address)value than the pointer belonging to an EARLIER // declared function? // // For example: // // Does this always evaluate to 'true'? // // if ( pntTst002 ) > ( pntTst000 ) {} // // // I need this functionality for running a statemachine stepping // through different states and I need to know if the current // selected state (to be executed) points to a later or an // earlier previous executed state-function. // // Thanks // // Henk
The C51 compiler hates function pointers.
Consider using a numeric state instead, and a switch statement that calls the individual functions.
It doesn't really hate them - but it imposes some very strict limitations on their use...
It - or at least the end user - does hate them because of the problem performing call tree analysis.