【发布时间】:2020-12-29 13:49:36
【问题描述】:
我有一个程序出现错误:
variable modified 'artikel'at file scope
char artikel[ARTNAME];
我想我必须添加一个#define,但我不明白具体是哪一个。
这是我的代码:
#include <stdio.h>
#include <string.h>
const int ARTNAME = 100;
typedef struct artikel {
char artikel[ARTNAME];
int anzahl;
} artikel;
int main()
{
}
【问题讨论】:
-
#define ARTNAME 100。 variably modified array at file scope in C -
我添加了#define ARTNAME 100,现在它给了我----> main.c:5:20: error: expected identifier or '(' before numeric constant #define ARTNAME 100跨度>
-
无法复制:godbolt.org/z/1Mo69q
-
要按原样编译此代码,您可以打开
C99或更高标准。它不会通过旧的C标准。 -
@flavio,你没有添加
#define。您将ARTNAME的现有声明更改 为#define。
标签: c