Search code examples
cdebuggingembeddedwatchiar

How to display an array range via a pointer in the IAR IDE Watch window?


In the IAR Embedded Workbench I have a pointer pointing to a buffer in memory. When watching the pointer, I can see the contents of the word it points to. How can I tell the Watch view to list a range of the buffer, from the pointer onwards, for some specified length of elements?

For example, enter the expression:

myPtr[0..2]

will display information equivalent to the three expressions:

myPtr[0]
myPtr[1]
myPtr[2]

Solution

  • From the Iar Embedded Workbench (9.20) help:

    In windows where you can edit the Expression field and in the Quick Watch window, you can specify the number of elements to be displayed in the field by adding a semicolon followed by an integer. For example, to display only the three first elements of an array named myArray, or three elements in sequence starting with the element pointed to by a pointer, write:

    myArray;3
    

    To display three elements pointed to by myPtr, myPtr+1, and myPtr+2, write:

    myPtr;3
    

    Optionally, add a comma and another integer that specifies which element to start with. For example, to display elements 10–14, write:

    myArray;5,10
    

    To display myPtr+10, myPtr+11, myPtr+12, myPtr+13, and myPtr+14, write:

    myPtr;5,10