roberto.m

Pointer to function

Discussion created by roberto.m on May 5, 2011
Latest reply on May 6, 2011 by CompilerGuru

Hi to all,

I'm using pointer to function variable. In this way I can call different functions. But i see a strange behaviour in this code:

 

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */


typedef void (*task_t)(void);

 void hello (void);
 
task_t task = NULL;

void main(void) {

  EnableInterrupts;

  task = &hello;

  for(;:smileywink:
  {

    task();
    __RESET_WATCHDOG();
  }
}


void hello ()
{
}

 

In debug mode, Procedure window I see :

 

main()

hello()

<0202'P>

 

But hello() itsn't called anytime before!

In my opinion it is a mistake!

 

I'm using CW6.3. (i try also in CW 6.2: same result) 

Outcomes