This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

debug messages using ifdef

Hi,

there's one pin depending on his level (high or low), the programm should / or should not transmit all the rs232 debug messages (printf()) to the hyperterminal.

How is it possible to use some #ifdefs | or is it much better to use a global variable?

#ifdef DEBUG_MODE
//debug mode - transmit all msg to the hyperterminal

#else
//no debug messages

#endif


int main(void)
{
  if(AT91C_BASE_PIOA->PIO_PDSR & 0x10)
  {
     /* -> transmit rs232 debug messages */

  } else {

    /* do not transmit any debug messages */
  }

   printf("only tansmit the msg if DEBUG_INIT is true");

  while(1);
}

best regards
Tim

Parents
  • You don't say! Seriously, though: it's pointless to worry about time or space efficiency after you've started using printf().

    That's the point. So maybe it's much better to decide at compiler time if I want to see the debug messages or not (without of the use of the pin state). But how is it possible to do that with #ifdef?

Reply
  • You don't say! Seriously, though: it's pointless to worry about time or space efficiency after you've started using printf().

    That's the point. So maybe it's much better to decide at compiler time if I want to see the debug messages or not (without of the use of the pin state). But how is it possible to do that with #ifdef?

Children