Keil™, An ARM® Company

Technical Support

C166: #IFDEF CAUSING STRING TEST PROBLEMS


Information in this article applies to:

  • C166 Version 4.03

QUESTION

I have written the following code:

#include <string.h>

#define SPECIAL

int x = 0;
char label[10];

void foo(void) { x = 1; }

void main(void)
{

#ifdef SPECIAL
  if (!*label) strcpy(label,"Online");
#endif
  if (*label) foo();

  while(1);
}

The function foo() should be called when SPECIAL is defined as the string label is no longer null.

However, the function is not called. If I assign "Online" to the string label at declaration time, the function foo() is called. Is there a fix for this?

ANSWER

This was a problem in C166 V4.04 and earlier. It was corrected in C166 Version 4.05. You may download the latest updates from the Keil Website.

Last Reviewed: Tuesday, June 15, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure