Next: Dynamic Arrays in C, Previous: Column-major Format, Up: Multi-dimensional Array Format

#### 3.2.3 Fixed-size Arrays in C

A multi-dimensional array whose size is declared at compile time in C is already in row-major order. You don't have to do anything special to transform it. For example:

         {
              fftw_complex data[N0][N1][N2];
              fftw_plan plan;
              ...
              plan = fftw_plan_dft_3d(N0, N1, N2, &data[0][0][0], &data[0][0][0],
                                      FFTW_FORWARD, FFTW_ESTIMATE);
              ...
         }

This will plan a 3d in-place transform of size `N0 x N1 x N2`. Notice how we took the address of the zero-th element to pass to the planner (we could also have used a typecast).

However, we tend to discourage users from declaring their arrays in this way, for two reasons. First, this allocates the array on the stack (“automatic” storage), which has a very limited size on most operating systems (declaring an array with more than a few thousand elements will often cause a crash). (You can get around this limitation on man1 systems by declaring the array as `static` and/or global, but that has its own drawbacks.) Second, it may not optimally align the array for use with a SIMD FFTW (see SIMD alignment and fftw_malloc). Instead, we recommend using `fftw_malloc`, as described below.