ROBOTC.net forums
http://www.robotc.net/forums/

Array of pointers to arrays
http://www.robotc.net/forums/viewtopic.php?f=11&t=7171
Page 1 of 1

Author:  jnmacdnld [ Sun Nov 03, 2013 12:28 pm ]
Post subject:  Array of pointers to arrays

Arrays are pointers to the first value of the array, so why doesn't this compile?

Code:
#ifndef MOTOR_LUTS
#define MOTOR_LUTS

int* motorLuts[10];

int backLeftDriveSettingLut[128] =
{
0, 29, 29, 29, 30, 30, 30, 30, 30, 30,
31, 31, 31, 32, 32, 32, 32, 32, 32, 33,
33, 33, 33, 33, 33, 33, 34, 34, 34, 34,
34, 35, 35, 36, 37, 37, 38, 38, 38, 39,
39, 39, 39, 39, 39, 40, 40, 40, 40, 40,
41, 41, 41, 41, 42, 44, 43, 45, 45, 45,
45, 45, 46, 46, 46, 46, 46, 49, 47, 48,
50, 50, 50, 51, 51, 51, 51, 54, 52, 55,
53, 53, 53, 53, 53, 56, 56, 56, 56, 56,
59, 63, 60, 62, 62, 61, 61, 64, 64, 64,
67, 65, 65, 70, 70, 71, 69, 69, 74, 74,
72, 73, 75, 78, 78, 76, 76, 76, 79, 79,
81, 80, 80, 82, 82, 82, 83, 83
};

void InitMotorLuts() {
  motorLuts[backLeftDrive] = backLeftDriveSettingLut;
}

#endif /* MOTOR_LUTS */


Code:
**Error**:Internal Compiler: Pointer assignment on non-pointer RValue
*Warning*:Read references exist to variable 'motorLuts', but its value is never initialized


EDIT: motorLuts[backLeftDrive] = &backLeftDriveSettingLut works, but I want to be able to access values like motorLuts[backLeftDrive][10], for example. (From what I understand, &backLeftDriveSettingLut is a pointer to a pointer.) I don't have a cortex to test this on, but would it work?

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/