I have a program where I get the error: variable modified 'artikel'at file scope char artikel[ARTNAME];
I don't think you have copied the diagnostic accurately. It is surely complaining about struct artikel
being variably modified.
That is closely related to the issue covered in Variably modified array at file scope in C. Specifically, const
qualification notwithstanding, ARTNAME
is not a "constant expression" in C, so the type of array artikel.artikel
and therefore also of the whole struct artikel
are "variably modified". Objects with variably modified types cannot be declared at file scope.
I think I have to add a #define, but I don't understand exactly which one.
The quickest solution would probably be to change this ...
const int ARTNAME = 100;
... to:
#define ARTNAME 100