[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


Using Vector Variables in Expressions (Mac OS)

You can use vector variables in expressions. Vector variables are defined as opaque structures in the C programming language, but you might find it useful to access the scalar elements inside the vector variable while debugging.

You can drag a vector variable into the Variable window or the Expressions window to change the values of its elements, but you sometimes still need to access the elements in expressions.

The C language does not provide the ability to access elements in expressions. However, the CodeWarrior IDE allows such access (only in expressions, not in your source code) by using unary operators.

Suppose you define an unsigned short variable x. You can access any of the scalar elements in x with the following statement:


  x.[index]

The index is an integer from 0-7 (there are 8 shorts) that represents the element that you wish to access.

You can use the following notation in equality tests or other expression statements:


  x.[0] >= 0x12

More usefully, you can use the following notation to set a conditional breakpoint:


  o main, line 765 | x.[0] == 0xFFFF

You cannot access vectors in the Expressions window by register name. For example, the following expressions are invalid:


  šVR31
  šVR30 == 'some 128-bit number'
  šVR29.[3]
  šVR28.[0] == 0xDEADBEEF

To avoid this situation, access a vector through its variable identifier. If you must manipulate or examine a register for which a variable identifier does not exist, use the AltiVec Registers window.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 17, 2000