C - initializer element is not constant -


here's snippet of code in c:

const char *d = "dictionary.dict";  struct dictionary *dict =         dictionary_load_lang(d); // compile error here 

the type of dictionary_load_lang() struct dictionary *dictionary_load_lang(const char *lang).

when trying compile compiler says "initializer element not constant" , can't see why. what's going on?

dictionary_load_lang() function, hence non-constant. can't use non-constants static storage variables (read: global and/or static):

as per c99 standard: section 6.7.8:

all expressions in initializer object has static storage duration shall constant expressions or string literals.

however, can such initialization if within function , non-static variable.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -