4 ms·
So I spend a possibly unreasonable amount of time and page space discussing VLAs in the Effective C book. I understand there are some problems with them, but fo
by rseacord 6y ago
So I spend a possibly unreasonable amount of time and page space discussing VLAs in the Effective C book. I understand there are some problems with them, but for what it is worth, I really like the feature, particularly when used in function prototype scope.
- jedbrown 6y agoI usually don't let them leak into public interfaces, and don't allocate VLAs, but really like VLA pointers for multi-dimensional array processing such as []: double (*a)[N][P] = (double (*)[N][P])a_flat; for (i=0; i<M; i++) for (j=0; j<N; j++) for (k=0; k<P; k++) a[i][j][k] = f(i, j, k); The alternative would be a_flat[(i*M+j)*P+k] = f(i, j, k); which is a lot more error-prone. I understand that some implementation (MSVC) declined to implement VLAs, but I really wish that at least VLA-pointers could have remained a mandatory part of C11 and later standards. [] Has there been any discussion of adding GCC's "typeof" to the standard?