int remainder [16] redeclared as different kind of symbol

Status
Not open for further replies.

boxxofrobots

Well-known member
The following snippet of code is from a supposedly working arduino sketch to generate a euclidian pattern. However, even when I try to compile the original, full sketch I get this same error, which I do not understand. Can someone help explain this please?

Thanks


Code:
void setup() {
  // put your setup code here, to run once:

}
int channel = 0;
int remainder[16];
int count[16];
int level;
int state = 0;
int stateArray[6][16];
int beat[6] = {0, 0, 0, 0, 0, 0};

void compute_bitmap(int num_slots, int num_pulses, int channel)  {
  int steps, pulses;

  if (num_pulses > num_slots) {
    num_pulses = num_slots;
  }
  int divisor = num_slots - num_pulses;
  steps = num_slots; pulses = num_pulses;
  remainder[0] = num_pulses;
  level = 0;
  do {
    count[level] = divisor / remainder[level];
    remainder[level + 1] = divisor % remainder[level];
    divisor = remainder[level];
    level = level + 1;
  }
  while (remainder[level] > 1);

  count[level] = divisor;
  build_string (level, channel);

}

//Bjorklund accessory function to build the output..
void build_string (int level, int channel)  {
  if (level == -1) {

    Serial.println('0'); // Debug
    stateArray[channel][state] = 0; //insert 0 into array
    state = state + 1;  //move to next
  }
  else if (level == -2)  {

    Serial.println('1');  // Debug
    stateArray[channel][state] = 1; //insert 1 into array
    state = state + 1;  //move to next
  }
  else {
    for (int i = 0; i < count[level]; i++)
      build_string(level - 1, channel);
    if (remainder[level] != 0)
      build_string(level - 2, channel);
  }

}
void loop() {
  // put your main code here, to run repeatedly:

}
 
"int" can be different sizes on different platforms. Arduino's 8 bit AVR versus 32 bit ARM used on Teensy.

Not sure how many bytes/bits are in an AVR 'int': Replacing int might work with either :: int8_t or int16_t to specify that used size versus the Teensy default of int32_t.
 
I believe that in this case it is simply that symbol named remainder is used by a library header file included indirectly by <Arduino.h>
Code:
bar:6: error: 'int remainder [16]' redeclared as different kind of symbol
 int remainder[16];
                 ^
In file included from C:\arduino-1.8.13\hardware\teensy\avr\cores\teensy4/WProgram.h:36:0,
                 from C:\Users\kurte\AppData\Local\Temp\arduino_build_715607\pch\Arduino.h:6:
c:\arduino-1.8.13\hardware\tools\arm\arm-none-eabi\include\math.h:349:15: note: previous declaration 'double remainder(double, double)'
 extern double remainder _PARAMS((double, double));
               ^
 
Status
Not open for further replies.
Back
Top