Hallo zusammen,
ich habe mal wieder gemerkt, daß ich Verständnislücken im Bereich 
"Konstanten" unter C habe:
Ich habe ein großes Struct definiert:
1  | const conf_t Conf[] =
  | 
2  | {
 | 
3  |   {   // Stop
 | 
4  |     .GPIOx    = GPIOA,
  | 
5  |     .GPIO_Pin = GPIO_Pin_0,
  | 
6  |     //[...]
  | 
7  |   },
  | 
8  | 
  | 
9  |   {   // Pause, feed hold
 | 
10  |     .GPIOx    = GPIOA,
  | 
11  |     .GPIO_Pin = GPIO_Pin_1,
  | 
12  |     //[...]  
  | 
13  |   }
  | 
14  |   //[...]
  | 
15  | },
  | 
16  | 
  | 
17  | const uint32_t nConf = sizeof(Conf)/sizeof(Conf[0]);
  | 
Die Größe der Konstanten "nConf" ist zur Compilezeit bekannt. Erzeuge 
ich innerhalb einer Funktion allerdings ein Array mit dieser Größe:
1  | void fcn(void)
  | 
2  | {
 | 
3  |    static uint_fast8_t helpbuf[nConf];
  | 
4  | 
  | 
5  | 
  | 
6  | }
  | 
so wird mir das mit der Fehlermeldung
1  |    error: storage size of 'helpbuf' isn't constant
  | 
quittiert. Beides ist übrigens in der gleichen .c-Datei.
Was veranlaßt den Compiler zu der Behauptung, daß "nConf" kein zur 
Compilezeit bekannter, konstanter Ausdruck sei?
Die "Lösung" für die Implementierung kenne ich natürlich: Mit
1  | #define NCONF (sizeof(Conf)/sizeof(Conf[0]))
  | 
2  | void fcn(void)
  | 
3  | {
 | 
4  |    static uint_fast8_t helpbuf[NCONF];
  | 
5  | }
  | 
bekommt der Compiler seinen konstanten Ausdruck und ist zufrieden. Mich 
interessiert also nur: Warum ist eine Konstante kein konstanter 
Ausdruck?
Viele Grüße
W.T.