Search code examples
gccstm32eclipse-cdt

GCC+STM32: missing one element in array


I have faced with a strange problem. I have moved my project from Keil to STM32 IDE. (based on Eclipse and GCC). In Keil I don't have any problems. But in Eclipse there is. The CPU is STM32F030xC

I am defining an array of structures.

typedef struct
{
  int width; // Character width in bits.
  int offset; // Offset in bytes into font bitmap.
}
FONT_CHAR_INFO;
const FONT_CHAR_INFO microsoftSansSerif_18ptDescriptors[] = 
{
{2, 0},         // ! 
{6, 25},        // " 
{13, 50},       // # 
{11, 100},      // $ 

and so on. There are 94 elements. The size of the array should be 8 * 94 = 752 bytes But in linker map I see the size 744. And in debugger one element is missing. With the index of 60. The 60 index in memory points to 61 in array. Other elements are present.

Maybe that relates somehow with data align? But the size of array should be bigger. I am using compiler without optimization. What is going on?


Solution

  • 60th element in an ASCII table starting at ! = 33, is code 93; and the one just before that with code 92 is backslash (\). The C preprocessor understands the backslash at the end of line as a continuation mark, merges that line with the subsequent line, and as you have a line comment mark (//) just before that, the whole combined line is removed as a comment.

    Don't put backslash at the end of line.