function pointer can't Identify function

I use a array of function pointer to save my function. I can successfully use it in the ARDUINO IDE 1.6.5, but can't use it in the 1.6.6 and 1.6.7. :frowning:
It always appear an error like this:


Arduino:1.6.7 (Windows 10), board:"Arduino Yún"

LedCube_RunCharacter:30: error: 'IC1' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC2' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC3' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC4' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC5' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC6' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC7' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

LedCube_RunCharacter:30: error: 'IC8' was not declared in this scope

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

^

exit status 1
'IC1' was not declared in this scope

***********************************************************************************The program can not find the function.
This is my code : void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};
But I can normally use it before IDE 1.6.6 previous releases.
What should I do?

So, it looks like you are using a Yun, yes?

I have not used a Yun, but the error message is telling you that IC1 - IC8 are not defined. What are IC1 to IC8? Where are they declared?

Oh, and post all your code, not just a snippet so we can check things more easily.

And post your code inside code tags so it looks like this:

...code here...

@OP, you need to post your replies here, not report to moderators

Yes, I use the Yun. IC1 - IC8 is a name of my function.
But I can normally use it in IDE 1.6.5 releases

You still need to post your code.
In code tags.

shirata:
Yes, I use the Yun. IC1 - IC8 is a name of my function.
But I can normally use it in IDE 1.6.5 releases

You need to post the information we ask for or we cannot help you.

Post all your code, not just a snippet or we cannot see what is happening.

@shirata: Despite being asked to use code tags for your source code posting, you chose to ignore that advice. Before you post again, read Nick Gammon's two posts at the top of this Forum, especially on the use of code tags.

Has some one be playing with the function proto type generation?

@OP - You need to declare/define things BEFORE they are used in C/C++

Mark

Edit your previous posts and put the code inside code tags so it looks like this:

...code here

But, the answer to your problem is that you need to forward declare your functions before they are used in your function array.

So, it needs to look like this:

void IC1(byte reg, byte data);
void IC2(byte rg, byte data);
...
void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};

....
void IC1(byte reg, byte data){
  digitalWrite(CS1, LOW);
  SPI.transfer(reg);                 
  SPI.transfer(data);                 
  digitalWrite(CS1,HIGH);
}

void IC2(byte rg, byte dta){
  digitalWrite(CS2, LOW);
  SPI.transfer(rg);                 
  SPI.transfer(dta);                 
  digitalWrite(CS2,HIGH);
}
....
#include <SPI.h>  

const byte NOOP = 0x0;            //not working
const byte DECODEMODE = 0x9;      //
const byte INTENSITY = 0xA;       //ntensity
const byte SCANLIMIT = 0xB;       //limit
const byte SHUTDOWN = 0xC;        //
const byte DISPLAYTEST = 0xF;     //test

const byte CS1 = 2;
const byte CS2 = 3; 
const byte CS3 = 4; 
const byte CS4 = 5; 
const byte CS5 = 6; 
const byte CS6 = 7; 
const byte CS7 = 8; 
const byte CS8 = 9; 

void (*f[8])(byte reg, byte date) = {IC1, IC2, IC3, IC4, IC5, IC6, IC7, IC8};


void setup (){
  pinMode(SS, OUTPUT);
  pinMode(CS1, OUTPUT);
  digitalWrite(CS1, HIGH);
  
  SPI.begin();                  //Ic.1
  IC1(SCANLIMIT, 7);
  IC1(DECODEMODE, 0);
  IC1(INTENSITY, 3);
  IC1(DISPLAYTEST, 0);
  IC1(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC1(i + 1, 0);
  }
  
  pinMode(CS2, OUTPUT);
  digitalWrite(CS2, HIGH);
  
  SPI.begin();                  //Ic.2      
  IC2(SCANLIMIT, 7);
  IC2(DECODEMODE, 0);
  IC2(INTENSITY, 3);
  IC2(DISPLAYTEST, 0);
  IC2(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC2(i + 1, 0);
  }
  
  pinMode(CS3, OUTPUT);
  digitalWrite(CS3, HIGH);
  
  SPI.begin();                  //Ic.3
  IC3(SCANLIMIT, 7);
  IC3(DECODEMODE, 0);
  IC3(INTENSITY, 3);
  IC3(DISPLAYTEST, 0);
  IC3(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC3(i + 1, 0);
  }

  pinMode(CS4, OUTPUT);
  digitalWrite(CS4, HIGH);
  
  SPI.begin();                  //Ic.4
  IC4(SCANLIMIT, 7);
  IC4(DECODEMODE, 0);
  IC4(INTENSITY, 3);
  IC4(DISPLAYTEST, 0);
  IC4(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC4(i + 1, 0);
  }

  pinMode(CS5, OUTPUT);
  digitalWrite(CS5, HIGH);
  
  SPI.begin();                  //Ic.5
  IC5(SCANLIMIT, 7);
  IC5(DECODEMODE, 0);
  IC5(INTENSITY, 3);
  IC5(DISPLAYTEST, 0);
  IC5(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC5(i + 1, 0);
  }
  
  pinMode(CS6, OUTPUT);
  digitalWrite(CS6, HIGH);
  
  SPI.begin();                  //Ic.6
  IC6(SCANLIMIT, 7);
  IC6(DECODEMODE, 0);
  IC6(INTENSITY, 3);
  IC6(DISPLAYTEST, 0);
  IC6(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC6(i + 1, 0);
  }
  
  pinMode(CS7, OUTPUT);
  digitalWrite(CS7, HIGH);
  
  SPI.begin();                  //Ic.7
  IC7(SCANLIMIT, 7);
  IC7(DECODEMODE, 0);
  IC7(INTENSITY, 3);
  IC7(DISPLAYTEST, 0);
  IC7(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC7(i + 1, 0);
  }
  
  pinMode(CS8, OUTPUT);
  digitalWrite(CS8, HIGH);
  
  SPI.begin();                  //Ic.8
  IC8(SCANLIMIT, 7);
  IC8(DECODEMODE, 0);
  IC8(INTENSITY, 3);
  IC8(DISPLAYTEST, 0);
  IC8(SHUTDOWN, 1);
  
  for (byte i = 0; i < 8; i++){
    IC8(i + 1, 0);
  }
  Serial.begin(9600);
  
}

void loop() {


}


void IC1(byte reg, byte data){
  digitalWrite(CS1, LOW);
  SPI.transfer(reg);                 
  SPI.transfer(data);                
  digitalWrite(CS1,HIGH);
}
void IC2(byte rg, byte dta){
  digitalWrite(CS2, LOW);
  SPI.transfer(rg);               
  SPI.transfer(dta);              
  digitalWrite(CS2,HIGH);
}
void IC3(byte reg, byte data){
  digitalWrite(CS3, LOW);
  SPI.transfer(reg);              
  SPI.transfer(data);             
  digitalWrite(CS3,HIGH);
}
void IC4(byte reg, byte data){
  digitalWrite(CS4, LOW);
  SPI.transfer(reg);                 
  SPI.transfer(data);                
  digitalWrite(CS4,HIGH);
}
void IC5(byte reg, byte data){
  digitalWrite(CS5, LOW);
  SPI.transfer(reg);                
  SPI.transfer(data);               
  digitalWrite(CS5,HIGH);
}
void IC6(byte reg, byte data){
  digitalWrite(CS6, LOW);
  SPI.transfer(reg);              
  SPI.transfer(data);            
  digitalWrite(CS6,HIGH);
}
void IC7(byte reg, byte data){
  digitalWrite(CS7, LOW);
  SPI.transfer(reg);             
  SPI.transfer(data);            
  digitalWrite(CS7,HIGH);
}
void IC8(byte reg, byte data){
  digitalWrite(CS8, LOW);
  SPI.transfer(reg);                 
  SPI.transfer(data);               
  digitalWrite(CS8,HIGH);
}

?

Mark

See post #9 to solve your problem.

Thank you!!
But why can I normal use it in IDE 1.6.5 releases ?
I have used it before IDE update!! :o

The IDE adds the prototypes automatically, but the new build system introduced in 1.6.6 puts them too late.