c - Why can't gsl_vector_alloc be called before main starts? -


From Book 21st Century:

Fixed variable, even one Inside the function, when the program starts, before the main starts, you can not start them with a non-fixed value.

  // This fails: gsl_vector_alloc () can not call the gsl_vector_alloc () before the main () static gsl_vector * Scratches = GSL_Vector_loc (20);  

Why can not you say gsl_vector_alloc before the main startup?

What you quoted from the book is the answer, that is because it will not be consistent with the standard.

  For the continuity of an object, all the spec reserves in the beginning will be continuous expression or string literals.  

However, I believe that something like this is possible in C + + under certain conditions.


Comments

Popular posts from this blog

sql - Find last match with latest inserted name in table -

c# - XML serialize base class without knowing derived class -

ios - Invalid IPA: missing embedded provisioning profile. Are you sure this is an ad hoc? -