ARM Technical Support Knowledge Articles

#IFDEF CAUSING STRING TEST PROBLEMS

Applies to: C166 C Compiler

Answer


Information in this article applies to:


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.

ATTACHED FILES

Request the files attached to this knowledgebase article.

Article last edited on: 2004-06-15 13:58:06

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential