Structure not defined error

Hello I'm trying to create a structure of servo variables
I wrote
"struct finger {
Servo distal;
Servo middle;
Servo proxi;
Servo connplat;
};"

and when i'm compiling i get this notice
"projacthand.ino : 'finger' has not been declared
Error compiling"
Can anyone help me understand where is my mistake

You need to post your full code so we can see what's going on.

#include <Servo.h>
 //Create a new variable called finger where I placed four motor
 struct finger{
    Servo distal;
    Servo middle;
    Servo proxi;
    Servo connplat;
};
// Declaration of functions
/*int movement();
int onemove(int factor,finger a);
int handmove();*/
//

int pos;
int main() 
{
  
 finger Thumb;
 finger Index;
 finger Middle;
 finger Ring;
 finger pinky;
//Set Connections
Thumb.distal.attach(1);
Thumb.middle.attach(2);
Thumb.proxi.attach(3);
Thumb.connplat.attach(4);
//
Index.distal.attach(5);
Index.middle.attach(6);
Index.proxi.attach(7);
Index.connplat.attach(8);
//
Middle.distal.attach(9);
Middle.middle.attach(10);
Middle.proxi.attach(11);
Middle.connplat.attach(12);
//
Ring.distal.attach(13);
Ring.middle.attach(14);
Ring.proxi.attach(15);
Ring.connplat.attach(16);
//
pinky.distal.attach(17);
pinky.middle.attach(18);
pinky.proxi.attach(19);
pinky.connplat.attach(20);


Thumb.connplat.write(pos);
}

int finger_move(int factor,finger FingerVerable, int Angle, int Side)
{
   FingerVerable.distal.write(Angle);
  FingerVerable.middle.write(Angle*factor); 
  FingerVerable.proxi.write(Angle); 
  FingerVerable.connplat.write(Side); 
  
   
}

int hand_move()
{
  
}

It's not your fault. The problem is that the Arduino is generating function declarations for you and it is screwing it up because it does not cope correctly with function signatures that use types declared in the sketch file. Specifically, it puts the function declarations in the wrong place in the file.

If you are using a late enough version of the IDE I understand you can prevent the error by adding your own function declarations after the type declarations, thereby preventing the IDE from adding its own ones in the wrong place.

Alternatively, put your type declarations in a separate header file and #include the header at the top of your sketch.

Index.connplat.attach(;

can you show in my code where to put it

You seem to misunderstand, that is what is in your present code.
Something in what you pasted is wrong and I don't know what it is but do search a fix it!!!

lironaharon:
can you show in my code where to put it

In order to compile, your code must include declarations for any functions that are used before they are defined. To help you do this (or get in the way and make a right pig's ear of it, depending on your point of view) the IDE inserts function declarations for all of your functions. But it adds them in the wrong place; it adds them before the type declarations in your code, which means that any function declarations which depend on types you defined in that file won't compile.

To fix this, you can insert this statement in your code after you declare the finger type (this will only work for later versions of the IDE):

int finger_move(int factor,finger FingerVerable, int Angle, int Side);

Or, put the declaration of the finger struct in a header file and #include that header in your sketch file (this should work with all IDE versions).

I see you've included some declarations in your code for functions that aren't implemented, so I suggest you get rid of those.

I also see you've implemented the main() function. There are very few situations where that is the right thing to do, and this isn't one of them. The entry points to your sketch should be setup() and loop(), as shown in all the examples that ship with the IDE.

Also, when posting code please enclose it in [ code ] [ /code ] tags. You can insert them into a post by clicking on the # button in the edit window. You can fix your previous posts by editing them, selecting the code and clicking the # button to add the code tags. The code tags stop the forum software from munging your code, so that it displays properly.

#include <Servo.h>
 //Create a new variable called finger where I placed four motor
 struct finger{
    Servo distal;
    Servo middle;
    Servo proxi;
    Servo connplat;
};
int finger_move(int factor,finger FingerVerable, int Angle, int Side);
// Declaration of functions
/*int movement();
int onemove(int factor,finger a);
int handmove();*/
//

int pos;
int main() 
{
  
 finger Thumb;
 finger Index;
 finger Middle;
 finger Ring;
 finger pinky;
//Set Connections
Thumb.distal.attach(1);
Thumb.middle.attach(2);
Thumb.proxi.attach(3);
Thumb.connplat.attach(4);
//
Index.distal.attach(5);
Index.middle.attach(6);
Index.proxi.attach(7);
Index.connplat.attach(8);
//
Middle.distal.attach(9);
Middle.middle.attach(10);
Middle.proxi.attach(11);
Middle.connplat.attach(12);
//
Ring.distal.attach(13);
Ring.middle.attach(14);
Ring.proxi.attach(15);
Ring.connplat.attach(16);
//
pinky.distal.attach(17);
pinky.middle.attach(18);
pinky.proxi.attach(19);
pinky.connplat.attach(20);


Thumb.connplat.write(pos);
}

int finger_move(int factor,finger FingerVerable, int Angle, int Side)
{
   FingerVerable.distal.write(Angle);
  FingerVerable.middle.write(Angle*factor); 
  FingerVerable.proxi.write(Angle); 
  FingerVerable.connplat.write(Side); 
  
   
}

int hand_move()
{
  
}

Bitten by the "EverHelpful IDE" again. The IDE tries to help by providing function declarations in this case it throw stumbling blocks in your way by "guessing" wrongly the declaration for your function 'finger_move'.

Everyone has their own way of dealing with this. I'm on and older version of the IDE and use the following -

int finger_move(int factor, struct finger FingerVerable, int Angle, int Side)
{
    FingerVerable.distal.write(Angle);
    FingerVerable.middle.write(Angle * factor);
    FingerVerable.proxi.write(Angle);
    FingerVerable.connplat.write(Side);
}