ARM Technical Support Knowledge Articles

CODE STRINGS IN STRUCTS ARE NOT MERGED

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOM

Rearranging data structures assigned to code memory sometimes causes the total module code size to change. This occurs even when no other changes are made to the source file--only the order of code strings defined in the data structures.

For example, in the following program, the strings abcdef and 1234 exist only once in program memory, as expected.

#include <stdio.h>

struct DSTR  {
  unsigned short int arg;
  unsigned char code *strp;
};

static const struct DSTR code X1[]=
 { {1, "abcdef"},
   {1, "1234"} };

static const struct DSTR code X2[]=
 { {1, "1234"},
   {1, "abcdef"} };

void main (void) {
  while (1) {
    printf ("Test
");
  }
}

But if the sequence of the two data structures X1 and X2 is reversed as in the next example,

#include <stdio.h>

struct DSTR  {
  unsigned short int arg;
  unsigned char code *strp;
};

static const struct DSTR code X2[]=
 { {1, "1234"},
   {1, "abcdef"} };

static const struct DSTR code X1[]=
 { {1, "abcdef"},
   {1, "1234"} };

void main (void) {
  while (1) {
    printf ("Test
");
  }
}

the 1234 string is generated twice in code memory.

CAUSE

There was a problem in merging code strings in C51 that caused strings to sometimes get merged and sometimes not.

RESOLUTION

This problem is corrected in 7.08e and the 7.09 update. Text strings in structures are now merged properly.

You may download the latest updates from the Keil Website.

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-15 10:02:26

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