This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

C6000 compiler uses column major order?

I'm using CCSv6 with the TI C6000 compiler 7.4.11

I have several arrays, some with 2 dimensions (e.g.  a1[256][192]), some with 3 (e.g. a2[20][30][40])  In looking at the variables in the Variable view and the same locations in the memory view, it looks like the arrays are stored in column major order, i.e. the last index varying the fastest as you go thru memory addresses linearly.  I thought C use row major order (first index varies the fastest)  Is this non-standard behavior?  Or is it implementation dependent? 

Thanks

Mike

  • Here are some quotes from K&R (2nd Edition) page 112 ...

    In C, a two-dimensional array is really a one-dimensional array, each of whose elements is an array.  ... Elements are stored by rows, so the rightmost subscript, or column, varies fastest as elements are accessed in storage order.

    All C compilers, including those from TI, meet this standard.  Your description matches this behavior, except for one thing.  You call it column major order.  That is incorrect.  It is termed row major order.  In column major order, the leftmost index varies fastest.

    Thanks and regards,

    -George

  • Yes, of course. Had my indices and row/col mixed up, sorry. Mike