Add for loop header macro cvector_for_each_in to mimic frequently used range-based for cvectors. With this macro, it might be a good idea to remove cvector_for_each and cvector_free_each_and_free, because they break C89 compatibility. Declaring a variable is not permitted in C89. It might be a good idea to merge cvector_for_each_in if the other macros are removed, because cvector_utils.h only contains one macro.
Example usage of cvector_for_each_in:
int *it;
cvector_vector_type(int) v = NULL;
cvector_push_back(v, 10);
cvector_push_back(v, 12);
cvector_for_each_in(it, v) {
printf("%d\n", *it);
}
Add for loop header macro
cvector_for_each_in
to mimic frequently used range-based for cvectors. With this macro, it might be a good idea to removecvector_for_each
andcvector_free_each_and_free
, because they break C89 compatibility. Declaring a variable is not permitted in C89. It might be a good idea to mergecvector_for_each_in
if the other macros are removed, because cvector_utils.h only contains one macro.Example usage of
cvector_for_each_in
:The example prints out all members of cvector v.