Library problem

Hi everyone,
I'm writing a library for a personal project with Arduino, but when I try to include it in the arduino's idle it give me some errors that I can't explain:

Arduino:1.6.9 (Windows 7), Board:"Arduino/Genuino Micro"

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:16:5: error: 'l_shoulder_pitch' does not name a type

     l_shoulder_pitch.attach(A0);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:17:5: error: 'l_thigh_yaw' does not name a type

     l_thigh_yaw.attach(A5);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:18:5: error: 'l_shoulder_roll' does not name a type

     l_shoulder_roll.attach(2);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:19:5: error: 'l_elbow_roll' does not name a type

     l_elbow_roll.attach(13);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:20:5: error: 'l_thigh_roll' does not name a type

     l_thigh_roll.attach(3);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:21:5: error: 'l_thigh_pitch' does not name a type

     l_thigh_pitch.attach(A4);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:22:5: error: 'l_knee_pitch' does not name a type

     l_knee_pitch.attach(A3);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:23:5: error: 'l_foot_pitch' does not name a type

     l_foot_pitch.attach(A1);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:24:5: error: 'l_foot_roll' does not name a type

     l_foot_roll.attach(A2);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:25:5: error: 'r_shoulder_pitch' does not name a type

     r_shoulder_pitch.attach(11);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:26:5: error: 'r_thigh_yaw' does not name a type

     r_thigh_yaw.attach(6);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:27:5: error: 'r_shoulder_roll' does not name a type

     r_shoulder_roll.attach(4);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:28:5: error: 'r_elbow_roll' does not name a type

     r_elbow_roll.attach(12);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:29:5: error: 'r_thigh_roll' does not name a type

     r_thigh_roll.attach(5);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:30:5: error: 'r_thigh_pitch' does not name a type

     r_thigh_pitch.attach(7);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:31:5: error: 'r_knee_pitch' does not name a type

     r_knee_pitch.attach(8);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:32:5: error: 'r_foot_pitch' does not name a type

     r_foot_pitch.attach(10);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:33:5: error: 'r_foot_roll' does not name a type

     r_foot_roll.attach(9);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:13: error: 'eyes' is not a type

     pinMode(eyes, OUTPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected identifier before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:19: note: in expansion of macro 'OUTPUT'

     pinMode(eyes, OUTPUT);

                   ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ',' or '...' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:19: note: in expansion of macro 'OUTPUT'

     pinMode(eyes, OUTPUT);

                   ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:25: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(eyes, OUTPUT);

                         ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:13: error: 'echoPin' has not been declared

     pinMode(echoPin, INPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected identifier before numeric constant

 #define INPUT 0x0

               ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:22: note: in expansion of macro 'INPUT'

     pinMode(echoPin, INPUT);

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:43:15: error: expected ',' or '...' before numeric constant

 #define INPUT 0x0

               ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:22: note: in expansion of macro 'INPUT'

     pinMode(echoPin, INPUT);

                      ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:27: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(echoPin, INPUT);

                           ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:36:5: error: 'int Mark::pinMode(int, int)' cannot be overloaded

     pinMode(echoPin, INPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:5: error: with 'int Mark::pinMode(int, int)'

     pinMode(eyes, OUTPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:13: error: 'trigPin' is not a type

     pinMode(trigPin, OUTPUT);

             ^

In file included from sketch\test.ino.cpp:1:0:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected identifier before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:22: note: in expansion of macro 'OUTPUT'

     pinMode(trigPin, OUTPUT);

                      ^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:44:16: error: expected ',' or '...' before numeric constant

 #define OUTPUT 0x1

                ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:22: note: in expansion of macro 'OUTPUT'

     pinMode(trigPin, OUTPUT);

                      ^

In file included from C:\Users\Utente168\Desktop\test\test.ino:1:0:

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:28: error: ISO C++ forbids declaration of 'pinMode' with no type [-fpermissive]

     pinMode(trigPin, OUTPUT);

                            ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:37:5: error: 'int Mark::pinMode(int, int)' cannot be overloaded

     pinMode(trigPin, OUTPUT);

     ^

C:\Program Files (x86)\Arduino\libraries\Mark/Mark.h:35:5: error: with 'int Mark::pinMode(int, int)'

     pinMode(eyes, OUTPUT);

     ^

exit status 1

The library's code:

#ifndef Mark_h
#define Mark_h
#include "Arduino.h"
#include "Servo.h"
class Mark
{
    const int eyes = 16;
    const int echoP = 14;
    const int trigPin = 15;

    Servo   l_shoulder_pitch, l_thigh_yaw, l_shoulder_roll, l_elbow_roll, l_thigh_roll, l_thigh_pitch,
            l_knee_pitch, l_foot_pitch, l_foot_roll, r_shoulder_pitch, r_thigh_yaw, r_shoulder_roll,
            r_elbow_roll, r_thigh_roll, r_thigh_pitch, r_knee_pitch, r_foot_pitch, r_foot_roll;

    
    l_shoulder_pitch.attach(A0);
    l_thigh_yaw.attach(A5);
    l_shoulder_roll.attach(2);
    l_elbow_roll.attach(13);
    l_thigh_roll.attach(3);
    l_thigh_pitch.attach(A4);
    l_knee_pitch.attach(A3);
    l_foot_pitch.attach(A1);
    l_foot_roll.attach(A2);
    r_shoulder_pitch.attach(11);
    r_thigh_yaw.attach(6);
    r_shoulder_roll.attach(4);
    r_elbow_roll.attach(12);
    r_thigh_roll.attach(5);
    r_thigh_pitch.attach(7);
    r_knee_pitch.attach(8);
    r_foot_pitch.attach(10);
    r_foot_roll.attach(9);

    pinMode(eyes, OUTPUT);
    pinMode(echoPin, INPUT);
    pinMode(trigPin, OUTPUT);

    public:
        Mark();
        void eyesOn();
        void eyesOff();
        void eyesBlink();
        void wait();

};
#endif // MARK_H

.cpp

#include "Mark.h"

Mark::Mark()
{

};

void Mark::wait()
{

};

void Mark::eyesOn()
{
    digitalWrite(eyes, HIGH);
};

void Mark::eyesOff()
{
    digitalWrite(eyes, LOW);
};

void Mark::eyesBlink()
{
    digitalWrite(eyes, HIGH);
    delay(500);
    digitalWrite(eyes, LOW);
    delay(500);
};

Someone Can help me?
Thanks a lot.

Someone Can help me?

Without seeing your sketch? No. I'll guess, though, that you do not include Servo.h in the sketch.

In the sketch there is only an #include

#include <Mark.h>

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

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

}

So, the .ino file gets some stuff added to it, and renamed to a .cpp file, as it is copied into the build directory.

All files included in the .ino file are copied to the build directory, along with their corresponding source files.

The Servo library is not included in the sketch, so it is not copied to the build directory, so it is not available to be included in the Mark.h file, so the compiler has no idea what a Servo is.

I've tryed to include Servo.h in the sketch, but there are the same errors

How can you expect that code outside any function in the class definition would compile or even work?

class Mark
{
    const int eyes = 16;
    const int echoP = 14;
    const int trigPin = 15;

    Servo   l_shoulder_pitch, l_thigh_yaw, l_shoulder_roll, l_elbow_roll, l_thigh_roll, l_thigh_pitch,
            l_knee_pitch, l_foot_pitch, l_foot_roll, r_shoulder_pitch, r_thigh_yaw, r_shoulder_roll,
            r_elbow_roll, r_thigh_roll, r_thigh_pitch, r_knee_pitch, r_foot_pitch, r_foot_roll;

   
    l_shoulder_pitch.attach(A0); // from here
    l_thigh_yaw.attach(A5);
    l_shoulder_roll.attach(2);
    l_elbow_roll.attach(13);
    l_thigh_roll.attach(3);
    l_thigh_pitch.attach(A4);
    l_knee_pitch.attach(A3);
    l_foot_pitch.attach(A1);
    l_foot_roll.attach(A2);
    r_shoulder_pitch.attach(11);
    r_thigh_yaw.attach(6);
    r_shoulder_roll.attach(4);
    r_elbow_roll.attach(12);
    r_thigh_roll.attach(5);
    r_thigh_pitch.attach(7);
    r_knee_pitch.attach(8);
    r_foot_pitch.attach(10);
    r_foot_roll.attach(9);

    pinMode(eyes, OUTPUT);
    pinMode(echoPin, INPUT);
    pinMode(trigPin, OUTPUT);  // to here

    public:
        Mark();
        void eyesOn();
        void eyesOff();
        void eyesBlink();
        void wait();

};

Damn you're right, thank you very much :smiley: